Skip to main content
Question

How can I update CuryUnitPrice without triggering 'Manual Price'


darylbowman
Captain II
Forum|alt.badge.img+13

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 🙏🏼

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings