Question

How can I update CuryUnitPrice without triggering 'Manual Price'

  • 11 January 2024
  • 0 replies
  • 68 views

Badge +11

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


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved