Wednesday, 17 July 2024

Move custom field data to CustTrans or VendTrans from LedgerJournalTrans D365FO X++

 

Many times there are custom fields created on LedgerJournalTrans need the same information on Customer transactions. It can be achieved by extending existing class.

For this you need to extend existing class called CustVoucher


For customer data


[ExtensionOf(Classstr(CustVoucher))]

final class CustVoucher_Extension

{


 protected void initCustVendTrans(CustVendTrans _custVendTrans, LedgerVoucher                 _ledgerPostingJournal, boolean _useSubLedger) 

  {

    LedgerJournalTrans ledgerJournalTransLocal;

    next initCustVendTrans(_custVendTrans, _ledgerPostingJournal, _useSubLedger);

    CustTrans custTrans = _custVendTrans as CustTrans;  // Get custTrans table buffer form CustVendTrans map instance


    if (common.TableId == tableNum(LedgerJournalTrans)) 

    {

      LedgerJournalTrans ledgerJournalTrans = common;  // Get journalLine table buffer


      custTrans.CustomField1 = ledgerJournalTrans.CustomeField1;

      custTrans.CustomField2 = ledgerJournalTrans.CustomeField2;

    }

  }

}


Same way you can do for Vendor data. Use VendVoucher


No comments:

Post a Comment