Monday, November 27, 2023

Code to Populate Custom field data from PurchTable to VendInvoiceJour in D365 f&o X++

[ExtensionOf(tableStr(VendInvoiceJour))]

public final class DaxVendInvoiceJour_Extension

{

   public void insert()

   {

       PurchTable      purchTable = PurchTable::find(this.PurchId);

       this.Dax_Remarks = purchTable.Dax_Remarks;

       next insert();

   }

}

...............

OtherWay:

[ExtensionOf(classStr(FormletterService))]

 internal final class DaxFormLetterServiceClass_Extension

 {

    protected void processJournal(Printout _printout)

    {

         VendInvoiceJour         vendInvoiceJourlocal;

         PurchTable              purchTable;

         next processJournal(_printout);

        select forupdate vendInvoiceJourlocal 

            join purchTable

                where vendInvoiceJourlocal.ParmId == parmId

                && vendInvoiceJourlocal.purchId == purchTable.purchId;

        ttsbegin;

        vendInvoiceJourlocal.Dax_Remarks = purchTable.Dax_Remarks; // custom field

        vendInvoiceJourlocal.update();

        ttscommit;

     }

 }

.........................

Other Way :

[ExtensionOf(classStr(PurchFormLetter_Invoice))]

internal final class DaxPurchFormLetter_Invoice_Extension

{

   protected void runRemainUpdates()

   {

       VendInvoiceJour     vendInvoiceJour;

       PurchTable          purchTable;

       str parmid = this.parmId();

       next runRemainUpdates();

       select forupdate vendInvoiceJour

           where vendInvoiceJour.ParmId == parmid;

       purchTable = PurchTable::find(vendInvoiceJour.PurchId);

       ttsbegin;

       vendInvoiceJour.Dax_Remarks = purchTable.Dax_Remarks;

       vendInvoiceJour.update();

       ttscommit;

   }

}

Output :


    





No comments:

Post a Comment