Hello everyone,
Whenever you add a new custom field to a payment journal, so then it’s become very important to flow that field to the posted transaction tables as well when that journal gets posted.
So today I’ll show you how you can implement a logic to flow a custom field from posted payment journal to a vendor/customer transaction table in D365 F&O using extensions and COC pattern.
VENDOR TRANSACTION
- Add a field (xyzExpenseCode) to the extensions of the LedgerJournalTrans table and LedgerJournalTransVendPaym form.
- Now add a field (xyzExpenseCode) to the extensions of the VendTrans table and form.
- Create an extension of VendVoucher class (VendVoucherxyz_Extension) to wrap the initCustVendTrans method to define the following mapping between journal and vendor transaction fields.
protected void initCustVendTrans(
CustVendTrans _custVendTrans,
LedgerVoucher _ledgerPostingJournal,
boolean _useSubLedger)
{
next initCustVendTrans(_custVendTrans, _ledgerPostingJournal, _useSubLedger);
VendTrans vendTrans = _custVendTrans as VendTrans; // Get vendTrans table buffer form CustVendTrans map instance
If (common == ledgerJournalTrans )
{
LedgerJournalTrans ledgerJournalTrans = common; // Get journalLine table buffer
vendTrans.xyzExpenseCode = ledgerJournalTrans.xyzExpenseCode; // Define mapping for custom fields
}
}
CUSTOMER TRANSACTION
- Add a field (xyzExpenseCode) to the extensions of the LedgerJournalTrans table and LedgerJournalTransCustPaym form.
- Similarly, add a field (xyzExpenseCode) to the extensions of the CustTrans table and form.
- Lastly, create an extension of CustVoucher class (CustVoucherxyz_Extension) to wrap the initCustVendTrans method to define the following mapping between journal and customer transaction fields.
protected void initCustVendTrans(
CustVendTrans _custVendTrans,
LedgerVoucher _ledgerPostingJournal,
boolean _useSubLedger)
{
next initCustVendTrans(_custVendTrans, _ledgerPostingJournal, _useSubLedger);
CustTrans custTrans = _custVendTrans as CustTrans; // Get custTrans table buffer form CustVendTrans map instance
If (common == ledgerJournalTrans )
{
LedgerJournalTrans ledgerJournalTrans = common; // Get journalLine table buffer
custTrans.xyzExpenseCode = ledgerJournalTrans.xyzExpenseCode; // Define mapping for custom fields
}
}
Now when you post a payment journal, so along with all other fields your custom field will also move to the respective transaction tables.
Happy Daxing,
References:









