Skip to main content
Solved

Copy UDF from PO Line to AP Invoice when entering AP Bill from PO

  • August 6, 2024
  • 28 replies
  • 418 views

Show first post

28 replies

Forum|alt.badge.img
  • Author
  • Freshman I
  • August 8, 2024

@darylbowman  @Vignesh Ponnusamy 

 

We installed the customization into  Acumatica 2023 R2 Build 23.212.0024 and It now works, thank you to both of you!


darylbowman
Captain II
Forum|alt.badge.img+16

Happy to help. Could you mark Vignesh’s post as the best answer?


tigrantunyan08
Freshman I

@lnd74 

Hello, I’ve faced a task like yours, and here is my code, maybe it will be useful:

We can convert IAPTranSource object to POReceiptLineS one, and find either POLine and POReceiptLine objects.

        #region Copy Customization Fields To APTran
        public delegate void CopyCustomizationFieldsToAPTranDelegate(APTran apTranToFill, IAPTranSource poSourceLine, bool areCurrenciesSame);

        [PXOverride]
        public virtual void CopyCustomizationFieldsToAPTran(APTran apTranToFill, IAPTranSource poSourceLine, bool areCurrenciesSame,
            CopyCustomizationFieldsToAPTranDelegate baseMetod)
        {
            UpdateAPTranFields(apTranToFill, (POReceiptLineS) poSourceLine);
            baseMetod(apTranToFill, poSourceLine, areCurrenciesSame);
        }
        #endregion

private void UpdateAPTranFields(APTran aPTran, POReceiptLineS recLine)
{
    if (recLine != null)
    {
        POReceiptLine poreceiptLine = GetReceiptLine(recLine.ReceiptNbr, recLine.ReceiptType, recLine.LineNbr);
        if (poreceiptLine != null)
        {
            var poReceiptLineExt = PXCache<POReceiptLine>.GetExtension<VEPOReceiptLineBExt>(poreceiptLine);
            UpdateAPTranFields(aPTran, poReceiptLineExt);
        }
        else
        {
            POLine poLine = GetPOLine(recLine.PONbr, recLine.POType, recLine.POLineNbr);
            if (poLine != null)
            {
                var poLineBOLExt = PXCache<POLine>.GetExtension<VEPOLineBOLExt>(poLine);
                UpdateAPTranBOLFields(aPTran, poLineBOLExt);
            }
        }
    }
}