Skip to main content

Hi I have 2 requirements,

  1. Copy Custom Field Values from Shipment Line to Invoice Line (SOShipLine → ARTran)
  2. 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!

@TharidhiP  Please use the below code to COPY the value from SOShipLine to ARTran and same way you try for other requirement as well.

 

  #region UsrAdditionalBox
PXDBBool]
PXUIField(DisplayName = "Test Box")]
PXDefault(typeof(Search<SOShipLineExt.usrAdditionalBox,
Where<SOShipLine.shipmentType, Equal<Current<ARTran.sOShipmentType>>,
And<SOShipLine.shipmentNbr, Equal<Current<ARTran.sOShipmentNbr>>,
And<SOShipLine.lineNbr, Equal<Current<ARTran.sOShipmentLineNbr>>>>>>),
PersistingCheck = PXPersistingCheck.Nothing)]

public virtual bool? UsrAdditionalBox { get; set; }
public abstract class usrAdditionalBox : PX.Data.BQL.BqlBool.Field<usrAdditionalBox> { }
#endregion

 


Hi @TharidhiP 

 

You could use a RowInserted Handler like so:

protected virtual void _(Events.RowInserted<POReceiptLine> e, PXRowInserted b)
{
POReceiptLine row = e.Row; //find current record
if(row == null) return;

POLine line = SelectFrom<POOrder>.Where<POLine.orderNbr.IsEqual<P.AsString>.And<POLine.orderType.IsEqual<P.AsString>>>.View.Select(base, row.PONbr, row.POType); // find related record in POLine table
if(order == null) return;

POReceiptLineExt rowExt = row.GetExtension<POReceiptLineExt>(row); //Get DAC Extension for POReceiptLine
POLineExt lineExt = line.GetExtension<POLineExt>(line); //Get DAC Extension for POLine


rowExt.UsrCustomField1 = lineExt.UsrCustomField1 //Set POReceipLine value.

}

 


Thanks @Naveen Boga and @aiwan for the suggestions!


Reply