I have the following code:
protected void SOLine_UsrMargin_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var salesOrderEntry = (SOLine)e.Row;
if (salesOrderEntry == null)
return;
decimal? lastCost = GetLastCost(salesOrderEntry.InventoryID);
decimal margin = (decimal)cache.GetValue<SOLineExt.usrMargin (salesOrderEntry); <-- Line 47
.
.
.
}
This code works fine when the user is adding/editing a Sales Order. They are getting the following Exception after they have save the Sales Order, create a Shipment and go to confirm it:
Object reference not set to an instance of an object.
Stack Trace: at PX.Objects.SO.SOOrderEntry_Extension.SOLine_UsrMargin_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) in g:\projects\xxx\Automatica\Projects\XXX\WebSite\App_RuntimeCode\SOOrderEntry.cs:line 47 at PX.Data.PXCache.OnFieldUpdated(String name, Object row, Object oldValue, Boolean externalCall) at PX.Data.PXCache`1.a(TNode A_0, TNode A_1, TNode A_2)
This is running on Acumatica Version 6.10.1122