update custom fields in BankAccountTrans from LedgerJournalTrans during the posting of the journal in D365FO. Here I am writing the code in the insert method for this I have used a pre-event handler. Check the below code.
class BankAccountTrans_Events { [PreHandlerFor(tableStr(BankAccountTrans), tableMethodStr(BankAccountTrans, insert))] public static void BankAccountTrans_Pre_insert(XppPrePostArgs args) { BankAccountTrans bankAccountTrans = Args.getThis(); LedgerJournalTrans ledgerJournalTrans; if (bankAccountTrans.SourceRecId && bankAccountTrans.SourceTableId && bankAccountTrans.SourceTableId == tableNum(LedgerJournalTrans)) { select firstonly1 ledgerJournalTrans where ledgerJournalTrans.RecId == bankAccountTrans.SourceRecId; bankAccountTrans.NewField1 = ledgerJournalTrans.NewField1; bankAccountTrans.NewField2 = ledgerJournalTrans.NewField2; } } }
Keep daxing!!
No comments:
Post a Comment