Skip to main content
Answer

Null reference exception occurs in 25R2 when my event handler supplies the second optional parameter

  • November 19, 2025
  • 4 replies
  • 48 views

jedmunds36
Jr Varsity III
Forum|alt.badge.img

I am getting examples of null reference exception error for some event handlers in 25R2 such as the following: 

[NullReferenceException: Object reference not set to an instance of an object.]
PX.Data.Generic`2.SearchAdapted(TGenericDelegate genericHandler, IEnumerable`1 classicHandlers) +258
PX.Data.Generic`2.GetClassicHandler(TGenericDelegate handler, Boolean remove) +100
PX.Data.RowInsertingEvents.AddAbstractHandler(Action`1 handler) +88
PX.Objects.IN.GraphExtensions.LineSplittingExtension`4.SubscribeForSplitEvents() +198
PX.Objects.IN.GraphExtensions.KitAssemblyEntryExt.INKitLineSplittingExtension.SubscribeForSplitEvents() +18
PX.Objects.IN.GraphExtensions.LineSplittingExtension`4.Initialize() +309
PX.Objects.IN.GraphExtensions.KitAssemblyEntryExt.INKitLineSplittingExtension.Initialize() +18
PX.Data.PXGraph.CreateInstance(Type graphType, String prefix) +573
PX.Web.UI.PXBaseDataSource.CreateDataGraphAsSingleton(Type type) +593
PX.Web.UI.PXBaseDataSource.CreateDataGraph(Type type) +152
PX.Web.UI.PXBaseDataSource.get_DataGraph() +414
PX.Web.UI.PXPage.GetAttributesFound() +84
PX.Web.UI.PXPage.EnableAttributes() +694
PX.Web.UI.PXPage.OnInit(EventArgs e) +88
System.Web.UI.Control.InitRecursive(Control namingContainer) +453
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1713

When reviewing the error, it suggests a problem with RowInserting for the split,

  PX.Data.RowInsertingEvents.AddAbstractHandler(Action`1 handler)

To overcome the problem I can comment out the second optional parameter (delegate) as shown below:


protected void _(Events.RowInserting<INKitTranSplit> e) //, PXRowInserting del)
{
//del?.Invoke(e.Cache, e.Args);
INKitTranSplit row = e.Row;

but this is not ideal.  The problem can occur with other events, all of them appear to involve the 

PX.Objects.IN.GraphExtensions.LineSplittingExtension in the stack trace. 

Has anyone else observed this issue?   I wish to keep the delegate option.

 

 

 

 

Best answer by jedmunds36

The answer from Case Support I think is helpful:


For most DACs, the system already has a base event handler wired in. This means when you write your own handler, you can hook into the system’s logic using the delegate parameter (e.g., PXRowInserting del). In those cases, the delegate points to the default behavior, so you can call it before or after your custom code to preserve the original functionality.

 

With split DACs such as SOLineSplit, INTranSplit etc the situation is different. These aren’t primary records — they’re used for allocations (splitting quantities across lots, serials, warehouses, etc.), and the system creates and manages them behind the scenes. They are controlled by the LineSplittingExtension framework. Because of this, there aren’t any base event handlers like RowInserting or FieldDefaulting. If you attempt to add a delegate parameter (such as PXRowInserting del) in a handler for SOLineSplit or INTranSplit, the delegate will always be null.

 

For example, there is no FieldDefaulting handler on the TransferLineSplittingExtension, which extends INTranSplit through the LineSplittingExtension logic. Split events are not explicitly defined within the graph; instead, they are dynamically injected through the SubscribeForSplitEvents method. You can add your handlers, like it is done in TransferLineSplittingExtension.

4 replies

jedmunds36
Jr Varsity III
Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • November 21, 2025

Much like split-level, the PX.Objects.IN.GraphExtensions.LineSplittingExtension error can occur for SubscribeForLineEvents() for line-level events like below, again when the second param (eg delegate) is described:

 

        protected void _(Events.FieldVerifying<ARTran.qty> e, PXFieldVerifying del)
{
// call the base BLC event handler...
del?.Invoke(e.Cache, e.Args);
ARTran row = e.Row as ARTran;
if (row == null) return;

but with a Field-level event, this can be avoided by describing the TTable in the first param:

        protected void _(Events.FieldVerifying<ARTran, ARTran.qty> e, PXFieldVerifying del)
{
// call the base BLC event handler...
del?.Invoke(e.Cache, e.Args);
ARTran row = e.Row as ARTran;
if (row == null) return;

 

 

 

 


jedmunds36
Jr Varsity III
Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • November 24, 2025

The following attached file highlights the problem on a new install of 25R2. 

Renaming it from a .txt to .cs file and dropping into App_Code makes an easy demonstration.

A Case Support has been started to learn more. 

 


jedmunds36
Jr Varsity III
Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • Answer
  • November 25, 2025

The answer from Case Support I think is helpful:


For most DACs, the system already has a base event handler wired in. This means when you write your own handler, you can hook into the system’s logic using the delegate parameter (e.g., PXRowInserting del). In those cases, the delegate points to the default behavior, so you can call it before or after your custom code to preserve the original functionality.

 

With split DACs such as SOLineSplit, INTranSplit etc the situation is different. These aren’t primary records — they’re used for allocations (splitting quantities across lots, serials, warehouses, etc.), and the system creates and manages them behind the scenes. They are controlled by the LineSplittingExtension framework. Because of this, there aren’t any base event handlers like RowInserting or FieldDefaulting. If you attempt to add a delegate parameter (such as PXRowInserting del) in a handler for SOLineSplit or INTranSplit, the delegate will always be null.

 

For example, there is no FieldDefaulting handler on the TransferLineSplittingExtension, which extends INTranSplit through the LineSplittingExtension logic. Split events are not explicitly defined within the graph; instead, they are dynamically injected through the SubscribeForSplitEvents method. You can add your handlers, like it is done in TransferLineSplittingExtension.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • November 25, 2025

Thank you for sharing the solution with the community ​@jedmunds36!