Generic Events Declaration

Hi Everyone,

Starting from Acumatica 2017 R2 you may notice a different events declaration. We call in generic events or new events declaration.
Here you can see an example for row and :

protected virtual void _(Events.FieldUpdated<DAC, DAC.field> e) {}
protected virtual void _(Events.FieldDefaulting<DAC, DAC.field> e) {}
protected virtual void _(Events.RowUpdated e) {}
protected virtual void _(Events.RowSelected e) {}
protected void _(Events.CacheAttached e) {}

From the functional side there is not difference between old and new events declarations.
However with generic events you have 2 main benifits:

  • No more mistakes in names of DACs or Fields. As you rerefence it by tipe whong name won’t be even compiled.
  • Don’t need to cast DACs anymore from e.Row anymore. It will have a typeinside.
    PXCache cache = e.Cache;
    DAC row = e.Row;

However there are a couple of important things you need to know about generic events:

  • Both new and old events can (but shouldn’t) be used simultaneously. I recommend you to use only one type of the events simultanoiusly. Otherwise it will be harder for you to seach for correct place of code.
  • You should use only “_” name for the generic events. It will help you to not duplicate them
  • If you mix new and old events – they will be collected from the Graph in the declaration sequence.
    • New *ed (and RowSelecting) events will be fired in original order (ascending)
    • New *ing events will be fired in reverse order (descending)

Ther are a couple of imitations also:

  • CacheAttached is supported only from Acumatica 2018R1 Update 8
  • Override event approach with 2 parameters isn’t yet supported. Use old events declaration with 3 parameters.
    protected void _(Events.RowInserting e, PXRowInserting baseHandler)

Have a nice Development!

6 Replies to “Generic Events Declaration”

  1. Pingback: Buy Backlinks
  2. When we use this syntax, how to Invoke base call, before executing our customization code.

    protected virtual void _(Events.FieldUpdated e)
    {
    InvokeBaseHandler?.Invoke(e.Cache, e);
    SOLine row = e.Row as SOLine;
    if (row != null)
    {
    }
    }

    1. Can you please advise, the below one properly coded

      protected virtual void _(Events.FieldUpdated e , PXFieldUpdated InvokeBaseHandler)
      {
      InvokeBaseHandler?.Invoke(e.Cache, e.Args);
      SOLine row = e.Row as SOLine;
      if (row != null)
      {

      }
      }

Leave a Reply

Your email address will not be published. Required fields are marked *