For Update Custom Fields In CustTrans/VendTrans From LedgerJournalTrans during the posting of the journal in D365FO. We have 2 ways.
Way 1:
For Vend trans:
[ExtensionOf(classStr(VendVoucherJournal))] final class VendVoucherJournal_Extension { protected void initCustVendTrans(CustVendTrans custVendTrans, LedgerVoucher _ledgerPostingJournal, boolean _useSubLedger = false) { LedgerJournalTrans ledgerJournalTrans; VendTrans vendTrans; next initCustVendTrans(custVendTrans, _ledgerPostingJournal, _useSubLedger); if (common.TableId == tablenum(LedgerJournalTrans)) { ledgerJournalTrans = common; vendTrans = custVendTrans; // Add new fields here. vendTrans.NewField1 = ledgerJournalTrans.NewField1; custVendTrans = vendTrans; } } }
For cust trans:
[ExtensionOf(classStr(CustVoucherJournal))] final class CustVoucherJournal_Extension { protected void initCustVendTrans( CustVendTrans custVendTrans, LedgerVoucher _ledgerPostingJournal, boolean _useSubLedger = false) { LedgerJournalTrans ledgerJournalTrans; recId recId; CustTrans custTrans; next initCustVendTrans(custVendTrans, _ledgerPostingJournal, _useSubLedger); if (common.TableId == tableNum(LedgerJournalTrans)) { recId = common.RecId; ledgerJournalTrans = LedgerJournalTrans::findRecId(recId, false); //ledgerJournalTrans = common; custTrans = custVendTrans; // Add new fields here. custTrans.NewField1 = ledgerJournalTrans.NewField1; custVendTrans = custTrans;// need to reassign the buffer } } }
Way 2:
[ExtensionOf(classStr(CustVendVoucher))] final class CustVendVoucher_Extension { public void post( LedgerVoucher _ledgerPostingJournal, CustVendTrans _custVendTrans, NoYes _approval, UnknownNoYes _euroTriangulation, boolean _withHoldTaxType, boolean _useSubLedger) { LedgerJournalTrans ledgerJournalTransLocal; VendTrans vendTrans; CustTrans custTrans; next post(_ledgerPostingJournal, _custVendTrans, _approval, _euroTriangulation, _withHoldTaxType, _useSubLedger); if (common.TableId == tableNum(LedgerJournalTrans)) { ledgerJournalTransLocal = common; if (_custVendTrans.tableid == tableNum(vendTrans)) { ttsbegin; select forupdate vendTrans where vendTrans.RecId == _custVendTrans.RecId; if (vendTrans.RecId) { vendTrans.NewField1 = ledgerJournalTransLocal.NewField1; vendTrans.Update(); } ttscommit; } else if (_custVendTrans.tableid == tableNum(CustTrans)) { ttsbegin; select forupdate custTrans where custTrans.RecId == _custVendTrans.RecId; if (custTrans.RecId) { custTrans.NewField1 = ledgerJournalTransLocal.NewField1; custTrans.Update(); } ttscommit; } } } }
Ref : update-custom-fields-in-custtrans-vendtrans-from-ledgerjournaltrans-during-the-posting-of-journal
Keep Daxing!!
No comments:
Post a Comment