We’re running 2023R2 and I’m trying to update the UnitPrice to equal the UnitCost when entering items in a “No Charge” Sales Order. Using the following code:
namespace PX.Objects.SO
{
public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{
// Update prices when order quantities updated
protected void _(Events.FieldUpdated<SOLine.orderQty> e)
{
var order = Base.Document.Current;
var line = e.Row;
if (order?.CustomerOrderNbr?.Contains("SE") == true && line != null)
{
// Use SetValueExt to ensure all business logic and UI updates occur
e.Cache.SetValueExt<SOLine.curyUnitPrice>(line, line.CuryUnitCost);
}
}
// Update prices when CustomerOrdNbr changes
protected void _(Events.FieldUpdated<SOOrder.customerOrderNbr> e)
{
if (e.NewValue?.ToString().Contains("SE") == true)
{
foreach (SOLine line in Base.Transactions.Select())
{
if (line.CuryUnitPrice > 0)
{
line.CuryUnitPrice = line.UnitCost;
Base.Transactions.Update(line);
}
}
}
}
}
}
I’ve been able to “update” a Sales Order to make it No Charge and have the UnitPrice adjusted properly by updating the CustomerOrderNbr but I haven’t been able to get it to work “in process”. Our default value for OrderQty is zero, so my thought was to update the UnitPrice when the OrderQty is updated. Unfortunately, my code won’t compile. I keep getting this error message:
\App_RuntimeCode\SOOrderEntry.cs(73): error CS1061: 'object' does not contain a definition for 'CuryUnitCost' and no accessible extension method 'CuryUnitCost' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
I’m sure it’s something simple that I’m missing. Anyone have any ideas as to what it might be?
Thanks.