Skip to main content
Question

Dynamically Removing/Adding Generically Defined Event Handlers

  • January 20, 2026
  • 1 reply
  • 28 views

epetruncio
Jr Varsity II

Since the introduction of the generically defined event hander (defined as ‘_’), has there ever been a method introduced to allow dynamically removing/adding the handler, or if we want to do this do we need to still define them in the classical sense (DAC_Field_EventType(PXCache cache, PXEventTypeEventArgs e)?

1 reply

Forum|alt.badge.img
  • Freshman I
  • January 21, 2026

No, Acumatica has not introduced a supported way to dynamically register/unregister the new “generic” event handlers (_) at runtime.

As of today, Acumatica has not introduced a supported mechanism to dynamically register or unregister the generic event handler syntax (handlers defined as _, e.g., protected virtual void _(Events.RowSelected<T> e)).

 

These generic handlers are intended to be statically discovered and bound by the framework at compile/runtime initialization, and they are not exposed as delegates that can be attached/detached dynamically.

Recommended approach for conditional behavior

If the requirement is simply to enable/disable logic based on configuration (feature flag, setup value, branch, etc.), the recommended pattern is to keep the generic handler and apply conditional logic inside it:

protected virtual void _(Events.RowSelected<APInvoice> e)

{

if (e.Row == null) return;

if (!MyFeatureEnabled())

return;

// handler logic here

}

If dynamic wiring is required

If you truly need to add handlers only under specific runtime conditions, you would still need to use the classic event subscription approach (or override patterns), such as:

1) Classic event method

protected virtual void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)

{

}

2) Runtime subscription in Initialize()

public override void Initialize()

{

base.Initialize();

Base.RowSelected.AddHandler<APInvoice>(APInvoice_RowSelected);

}