Skip to main content
Question

Object referance error when change OrderQty in Sales Orders

  • January 12, 2026
  • 4 replies
  • 49 views

I have a very strange problem with Modern UI. Here are the steps I take to get it: I create a sales order, set a kit, explode it, then without saving it, I create a new line with any item. When I try to set a QTY, it throws an object referencing error and role back qty to 0 on the tab and resets the QTY back to zero. This problem is related to Modern UI because Classic UI doesn't have this problem.

protected virtual void SOLine_OrderQty_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e, PXFieldUpdated baseMethod)
{
    baseMethod?.Invoke(sender, e);

    SOOrderEntry soGraph = (SOOrderEntry)sender.Graph;

    SOLine row = (SOLine)e.Row;
    if (row == null)
        return;

    BZSOLineExt rowExt = PXCache<SOLine>.GetExtension<BZSOLineExt>(row);
    if (rowExt == null)
        return;

    switch (rowExt.UsrBZExplodeState)
    {
        case null:
            return;
        case BZExplodeState.Never:
            return;
    }

    if (soGraph.IsContractBasedAPI || row.InventoryID == null || (decimal?)e.OldValue == row.OrderQty)
        return;

    if (sender.Graph.Accessinfo.ScreenID != BZKitMessages.SOShipmentScreenId && sender.Graph.Accessinfo.ScreenID != BZKitMessages.OpportunityScreenId && sender.Graph.Accessinfo.ScreenID != BZKitMessages.QuoteScreenId)
    {
        if (rowExt.UsrBZMarkForKitAssembly == true && rowExt.UsrBZKitAssemblyRefNbr == null && rowExt.UsrBZKitAssemblyDocType == null)
            return;

        BZSOSetupExt setupExt = PXCache<SOSetup>.GetExtension<BZSOSetupExt>(soGraph.sosetup.Current);
        INKitSpecHdr hdr = GetKitItemSpecHeader(soGraph, row.InventoryID);
        if (hdr != null)
        {
            if (rowExt.UsrBZIsReplacedKit != true && row.IsKit == true)
            {
                BZSOOrderEntryExt soGraphExt = soGraph.GetExtension<BZSOOrderEntryExt>();

                if (!(soGraphExt.ExplodeFromPopupButton == true))
                {
                    CheckForKitExplosion(sender, row, rowExt, setupExt, GetItemByID(sender.Graph, row.InventoryID), GetExplodeOption(setupExt, hdr));
                }
            }
        }
    }
}

There's something strange: if you comment out this code, there won't be a problem; it seems to trigger the problem when Modern UI is enabled.

 

4 replies

Forum|alt.badge.img+9
  • Captain II
  • January 16, 2026

@VaheGhazaryan 

 

Do you have commit changes set for the fields?


  • Author
  • Freshman I
  • January 16, 2026

@aiwan 

“Commit Changes” is enabled by default in Acumatica — it is currently set to True.


DipakNilkanth
Pro III
Forum|alt.badge.img+14

Hi ​@VaheGhazaryan, I believe this issue is occurring because the CheckForKitExplosion method is being executed inside the FieldUpdated event.

Since Modern UI is more sensitive to cache and row state changes during field updates, calling this logic there can lead to unexpected behavior.

Could you please try moving the CheckForKitExplosion logic to a safer event such as RowPersisting and test again? This should ensure the row is fully initialized and may resolve the issue.


Forum|alt.badge.img+2
  • Jr Varsity III
  • January 24, 2026

@VaheGhazaryan ,
                    I think this is a classic Modern UI event timing issue in Acumatica. The problem stems from how Modern UI handles field updates differently than Classic UI, particularly with asynchronous operations and cache state management.
can you try your code to move on RowUpdated event.