Hi,
I am implementing event handler RowInserted for Shipment with the goal: copy value a custom field from Sale Order and set it to the field on Shipment (also custom field).
Here is code:
protected void SOShipment_RowInserted(PXCache cache, PXRowInsertedEventArgs e)
{
var row = (SOShipment)e.Row;
var query = new SelectFrom<SOOrder>.InnerJoin<SOOrderShipment>.On<SOOrder.orderNbr.IsEqual<SOOrderShipment.orderNbr>
.And<SOOrder.orderType.IsEqual<SOOrderShipment.orderType>>>
.Where<Use<SOOrderShipment.shipmentNbr>.AsString.IsEqual<@P.AsString>>
.View(Base);
SOOrder order = query.Select(row.ShipmentNbr).TopFirst;
if(order!=null){
var orderExt=order.GetExtension<SOOrderExt>();
row.GetExtension<SOShipmentExt>().UsrInvoiceNote=orderExt.UsrSONotes;
}else{
row.GetExtension<SOShipmentExt>().UsrSONotes="SalesOrder is null";
}
Base.Caches[typeof(SOShipment)].Update(row);
}
However, I always get the value of field on Shipment is “SalesOrder is null”.
I also tried with to take SalesOrder from the subgrid by using:
var order=Base.OrderList.Select().FirstOrDefault();
Does anyone have idea?
Thank you,
Best answer by Naveen Boga
View original