Tuesday, September 23, 2025

Update custom fields in voucher transactions in D365F&O X++

The code below will work for voucher transactions that were created automatically.

[ExtensionOf(classStr(LedgerVoucherTransObject))]

internal final class Dax_LedgerVoucherObject_Extension

{

   public void initFromLedgerPostingTransaction(

       LedgerPostingTransactionTmp _ledgerPostingTransaction,

       LedgerPostingTransactionProjectTmp _projectPostingTransaction)

   {

       next initFromLedgerPostingTransaction(_ledgerPostingTransaction,_projectPostingTransaction);

 

       generalJournalAccountEntry.Dax_CosnsolidateAccount = "testloc"; //Custom field

   }

}

The code below will work for voucher transactions that are transferred manually or through a batch.

[ExtensionOf(classStr(SubledgerJournalTransferCommand))]

internal final class Dax_SubledgerJournalTransferCommand_Extension

{

   public void executeTransfer(SubledgerJournalTransferRequest subledgerJournalTransferRequest)

   {

       GeneralJournalAccountEntry          accountEntry;

       GeneralJournalEntry                 generalJournalEntryloc;

       SubledgerJournalEntry subledgerJournalEntry;

       next executeTransfer(subledgerJournalTransferRequest);

       select subledgerJournalEntry

          where subledgerJournalEntry.RecId == transferidVal;

       if(subledgerJournalEntry.Status == SubledgerJournalEntryStatus::Transferred)

       {

           select generalJournalEntryloc

              where generalJournalEntryloc.TransferId ==subledgerJournalEntry.TransferId;

           while select forupdate accountEntry

              where accountEntry.GeneralJournalEntry == generalJournalEntryloc.RecId

           {

               ttsbegin;

               accountEntry.Dax_CosnsolidateAccount = "test"; //Custom field

               accountEntry.update();

               ttscommit;

           }

       }

   }

}

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

Output :

The above code works for voucher transactions that were created in the following ways :

1.Scenario - Product receipt voucher transactions. Manually transfer


2.Vendor invoice journal


3.Vendor payment journal.
4.Sales Packing slip vouchers.
5.Sales order invoice vouchers.
6.Free text invoices.
7.General journals.
8.Movement journals.
9.Hour journals.
10.Expense journals
11.Fixed asset journals. etc..




 





No comments:

Post a Comment