Event handlers in Acumatica

Hello everybody,

today I want to share with you how order of event handlers in Acumatica is organized.

Each graph has list of event handlers for each type of manipultaion. Also new declarations of methods can be added to the start or then end of collection, and there are events which are added in the beginning of collection.

According to T300 event handlers which are added to the end of collection:

    • FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)

    • RowSelecting(PXCache sender, PXRowSelectingEventArgs e)

    • RowSelected(PXCache sender, PXRowSelectedEventArgs e)

    • RowInserted(PXCache sender, PXRowInsertedEventArgs e)

    • RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)

    • RowDeleted(PXCache sender, PXRowDeletedEventArgs e)

    • RowPersisted(PXCache sender, PXRowPersistedEventArgs e

Let's say we considered about RowPersisted event. Then the schema will be following:

Base.RowPersisted -> 1st level event handler -> 2nd level event handler. In other words, initially Acumatica code will be executed, and after your code will be executed.

There are also events which has another order which are added to the beginning of the collection:


• FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)

• FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)

• FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)

• FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)

• RowInserting(PXCache sender, PXRowInsertingEventArgs e)

• RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)

• RowDeleting(PXCache sender, PXRowDeletingEventArgs e)

• RowPersisting(PXCache sender, PXRowPersistingEventArgs e)

• CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)

• ExceptionHandling(PXCache sender, PXExceptionHandlingEventArgs e)

From RowPersisting prospective following chain will be executed:

2nd level.RowPersisting  -> 1st level.RowPersisting -> Base.RowPersisting. In other words initially your code will be executed, and only thereafter Acumatica code will be executed and (!!!!) modify your changes to some others. In my practice it was situation, that my changes to RowPersisting was lost because Acumatica basic code removed my code.

Probably you can have question, is there a way to modify this behaviour. What if I want to change order? Yes, it's possible. You just need to use PXAcumaticaEvent template. Look at code below:

protected void DAC_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated del)
  //your code can be here 
  if (del != null)
     del(sender, e);
  //or here. Or even in both places
Or you can even ignore calling of base code.
protected void DAC_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated del)
  //your code can be here 
In the second case basic code will not be executed.

With such tricks you can modify behavior in the way you like.

Add comment