Tuesday, September 2, 2025

How to Retrieve the Purchase Order Number in the LedgerTransAccount Form using X++ in D365 Finance & Operations

 How to Retrieve the Purchase Order Number in the LedgerTransAccount Form using X++ in D365 Finance & Operations

[ExtensionOf(tableStr(GeneralJournalEntry ))]

internal final class GeneralJournalEntryTable_Extension

{

 public display Name Ponumber()

    {

        Name                    ret;  

        VendInvoiceJour         VendInvoiceJour;

        VendTrans               VendTrans;

        VENDPACKINGSLIPVERSION  VENDPACKINGSLIPVERSION;

        VENDPACKINGSLIPJOUR     VENDPACKINGSLIPJOUR;


        select VendTrans

            where VendTrans.Voucher == this.SubledgerVoucher;


        select VendInvoiceJour where VendInvoiceJour.LedgerVoucher ==VendTrans.Voucher

            &&  VendInvoiceJour.InvoiceAccount ==VendTrans.AccountNum

            &&  VendInvoiceJour.InvoiceDate ==VendTrans.TransDate;

        if(VendInvoiceJour)

        {

            ret = VendInvoiceJour.PurchId;

        }

        

        SELECT VENDPACKINGSLIPJOUR FROM VENDPACKINGSLIPVERSION

            WHERE VENDPACKINGSLIPVERSION.LEDGERVOUCHER ==this.SubledgerVoucher;


        SELECT PACKINGSLIPId FROM VENDPACKINGSLIPJOUR

            WHERE VENDPACKINGSLIPJOUR.RECID == VENDPACKINGSLIPVERSION.VENDPACKINGSLIPJOUR;

        if(VENDPACKINGSLIPJOUR)

        {

            ret = VENDPACKINGSLIPJOUr.purchid;

        }


        return ret;

    }

}

No comments:

Post a Comment

Automating Consolidate Account Updates for New Voucher Transactions in D365 Finance and Operations

  Ensure the  Consolidate Account  field is automatically updated for all new voucher transactions based on the  Consolidate MainAccount set...