This code changes the default calculation for SOLine.CuryUnitPrice on SOOrderEntry:
protected virtual void _(Events.FieldDefaulting<SOLine, SOLine.curyUnitPrice> e, PXFieldDefaulting b)
{
SOLine row = e.Row;
if (row is null) return;
b?.Invoke(e.Cache, e.Args);
var rowExt = row.GetExtension<DSDSOLine_Ext>();
e.NewValue = (row?.OrderQty ?? 0m) * (row?.CuryUnitCost ?? 0m) * (rowExt?.UsrMultiplier ?? 0m);
e.Cancel = true;
}
There are several fields that when updated need to trigger this calculation. I do this exactly like the system does:
protected virtual void _(Events.FieldUpdated<SOLine, DSDSOLine_Ext.usrMultiplier> e)
{
SOLine row = e.Row;
if (row is null) return;
e.Cache.SetDefaultExt<SOLine.curyUnitPrice>(row);
}
Unfortunately, despite not actually setting the value of CuryUnitPrice anywhere except the FieldDefaulting event, ‘Manual Price’ gets set to true during this process. I can’t figure out why, and I can’t figure out how to prevent it.
The objective is to simply extend the out-of-box calculations and leave everything else intact.
Please help 🙏🏼