@param2022 I wouldn’t suggest to use the Barcode_FieldUpdated event for what you are trying to achieve since this field (Barcode) could be many things, not only Shipment Nbr: Shipment Nbr, Item, Location, etc..
It seems you have added a custom field in an extension (HeaderExt) at the header of PickPackShip and you want to copy that value to the selected shipment to another custom field (SOShipmentExt), am I right?
@Dioris Aguilar yes I want to add that HeaderExtension’s value to the shipment that is being currently scanned. I am not getting shipment Id so I used barcode as last resort.
@param2022 I suggest to save the value in SOShipment using a custom PXAction and a custo smartpanel.
You would add a new PXAction in a graphExt for PickPackShip.Host and this custom action will call a custom smartpanel (popup window) (here’s a reference on how to create smartpanels https://asiablog.acumatica.com/2015/11/using-smart-panel.html), this popup window (smartpanel) will prompt for the value you want to save to SOShipment.
@Dioris Aguilar I don’t know how I can add those changes to DB. I will face same issue over there. I want to know how I can update Database values.
@param2022 You can use the following code to save the changes to DB:
SOShipmentEntry shipmentEntry = PXGraph.CreateInstance<SOShipmentEntry>();
shipmentEntry.Document.Current = SelectFrom<SOShipment>.Where<SOShipment.shipmentNbr.IsEqual<@P.AsString>>.View.Select(shipmentEntry, shipmentNbr);
SOShipmentExt shipmentExt = shipment.GetExtension<SOShipmentExt>();
shipmentEntry.CurrentDocument.Cache.SetValueExt<SOShipmentExt.myField>(shipment, headerExt.MyField);
if (shipmentEntry.IsDirty)
{
shipmentEntry.Save.Press();
}
@Dioris Aguilar So I need to write this code in custom action ? As we in event handler it gives me error
Error “PX1043 Changes cannot be saved to the database from the event handler”
@param2022 Yes, that’s right. Add the code to a custom action and get the shipmentNbr from the header or get the first line in the details which is SOShipLineSplit and this record will also have the shipmentNbr.