Skip to main content
Solved

Dynamically Removing/Adding Generically Defined Event Handlers

  • January 20, 2026
  • 2 replies
  • 39 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)?

Best answer by FarhanaM60

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);

}

2 replies

Forum|alt.badge.img
  • Freshman II
  • Answer
  • 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);

}


epetruncio
Jr Varsity II
  • Author
  • Jr Varsity II
  • January 26, 2026

Thanks Farhana. I figured that was the case, but wanted to make sure. Anytime I need to dynamically add/remove handlers, I already define them in the classical way. As long as that is still acceptable through validation (with justification if needed), that’s all I need to know.