Hi,
I create a custom field named UsrInvoiceNote on Sale Order and Shipment. I am implementing a trigger handler when field this field is update on Sale Order. The main target is coping the value to linked Shipment.
Here is the snippet code:
protected void SOOrder_UsrInvoiceNote_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (SOOrder)e.Row;
var ext = row.GetExtension<SOOrderExt>();
// handle update shipment
var query = new SelectFrom<SOShipment>.InnerJoin<SOOrderShipment>.On<SOOrderShipment.shipmentNbr.IsEqual<SOShipment.shipmentNbr>>
.Where<Use<SOOrderShipment.orderType>.AsString.IsEqual<@P.AsString>.And<Use<SOOrderShipment.orderNbr>.AsString.IsEqual<@P.AsString>>>
.View(Base);
var shipments = query.Select(row.OrderType, row.OrderNbr);
foreach (SOShipment sm in shipments)
{
sm.UsrInvoiceNote = ext.UsrInvoiceNote;
Base.Caches[typeof(SOShipment)].Update(sm);
}
if (Base.Caches[typeof(SOShipment)].Updated.Cast<SOShipment>().Count() > 0)
{
Base.Caches[typeof(SOShipment)].Persist(PXDBOperation.Update);
}
}
I got the error as following:
error CS1061: 'PXResult<SOShipment>' does not contain a definition for 'UsrInvoiceNote' and no accessible extension method 'UsrInvoiceNote' accepting a first argument of type 'PXResult<SOShipment>' could be found (are you missing a using directive or an assembly reference?)
I have tried with using GetExtension but it didn’t work.
sm.GetExtension<SOShipmentExt>().UsrInvoiceNote=ext.UsrInvoiceNote;
Could you please give me the instruction how to perform update custom field in Shipment when updating a field in Sale Order?