Hi I have 2 requirements,
- Copy Custom Field Values from Shipment Line to Invoice Line (SOShipLine → ARTran)
- Copy Custom Field Values from Purchase Order Header to Purchase Receipt Header (POOrder → POReceipt)
How can I implement this?
Is there a way I can use PXOverride and update the fields on invoice line creation and purchase receipt creation.
For example this is an implementation I did for copying field values from sales order header to shipment header screen.
public delegate void CreateShipmentDelegate(CreateShipmentArgs args);
[PXOverride]
public void CreateShipment(CreateShipmentArgs args, CreateShipmentDelegate baseMethod)
{
// Call the original method to ensure default behavior
baseMethod(args);
// Retrieve the current shipment and order
SOShipment ship = Base.Document.Current;
SOOrder order = args.Order;
if (ship != null && order != null)
{
// Use the extension cache to access the custom fields
SOShipmentExt shipExt = PXCache<SOShipment>.GetExtension<SOShipmentExt>(ship);
SOOrderExt orderExt = PXCache<SOOrder>.GetExtension<SOOrderExt>(order);
// Update custom fields in the shipment header
shipExt.UsrCommission = orderExt.UsrCommission;
shipExt.UsrCustomerPickUp = orderExt.UsrCustomerPickUp;
shipExt.UsrDuty = orderExt.UsrDuty;
shipExt.UsrFreight = orderExt.UsrFreight;
shipExt.UsrInsurance = orderExt.UsrInsurance;
shipExt.UsrQtyShow = orderExt.UsrQtyShow;
shipExt.UsrQtyNote = orderExt.UsrQtyNote;
shipExt.UsrShippingTermsINCOTERM = orderExt.UsrShippingTermsINCOTERM;
shipExt.UsrCurrencyTerms = orderExt.UsrCurrencyTerms;
// Update and save the shipment header
Base.Document.Update(ship);
Base.Save.Press();
}
}
Thank you!