I’ve been having trouble getting a custom event handler to fire. I’ve followed this process...
...as closely as I could, and while the action that fires the event runs, the transition triggered by the event does not.
I feel like I’m missing something obvious, but I just can't put my finger on it.
I’m working with 24R1 Build 24.101.0059.
For context, this is more an exercise in personal edification than looking for a workaround.
Any input would be appreciated.
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class APInvoiceExtZ : PXCacheExtension<PX.Objects.AP.APInvoice>
{
public class Events : PXEntityEvent<APInvoice>.Container<Events>
{
public PXEntityEvent<APInvoice> DescChanged;
}
}
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class APInvoiceEntry_Ext : PXGraphExtension<APInvoiceEntry>
{
public PXAction<APInvoice> ChangeDescription;
nPXUIField(DisplayName = "ChangeDescription")]
)PXButton]
protected virtual IEnumerable changeDescription(PXAdapter adapter)
{
Base.Document.Current.DocDesc = "The Action changed this Description";
APInvoiceExtZ.Events
.Select(e => e.DescChanged)
.FireOn(Base, Base.Document.Current);
return adapter.Get();
}
#region Entity Event Handlers
public PXWorkflowEventHandler<APInvoice> OnDescChanged;
#endregion
}
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class APInvoiceEntry_WorklowExt : PXGraphExtension<APInvoiceEntry_Workflow, APInvoiceEntry_Ext, APInvoiceEntry>
{
public sealed override void Configure(PXScreenConfiguration config) { Configure(config.GetScreenConfigurationContext<APInvoiceEntry, APInvoice>()); }
protected static void Configure(WorkflowContext<APInvoiceEntry, APInvoice> context)
{
context.UpdateScreenConfigurationFor(screen =>
{
return
screen
.WithActions(actions =>
{
actions.Add<APInvoiceEntry_Ext>(g => g.ChangeDescription, a => a.WithCategory(PredefinedCategory.Actions));
})
.WithHandlers(handlers =>
{
handlers
.Add(handler =>
{
return
handler
.WithTargetOf<APInvoice>()
.OfEntityEvent<APInvoiceExtZ.Events>(e => e.DescChanged)
.Is<APInvoiceEntry_Ext>(g => g.OnDescChanged)
.UsesTargetAsPrimaryEntity()
.DisplayName("OnDescChanged");
});
})
.UpdateDefaultFlow(flow =>
flow
.WithFlowStates(fss =>
{
fss.Update<APDocStatus.hold>(flowState =>
{
return flowState
.WithActions(actions => actions.Add<APInvoiceEntry_Ext>(g => g.ChangeDescription))
.WithEventHandlers(handlers => { handlers.Add<APInvoiceEntry_Ext>(g => g.OnDescChanged); });
});
})
.WithTransitions(transitions =>
{
transitions.UpdateGroupFrom<APDocStatus.hold>(ts =>
ts.Add(t => t
.To<APDocStatus.balanced>()
.IsTriggeredOn<APInvoiceEntry_Ext>(g => g.OnDescChanged)
)
);
})
);
});
}
}