Say, we need to add a new field UniqueId to LedgerJournalTrans and then have it populated in GeneralJournalAccountEntry, once a General journal posted.
In other words the field value must be transferred from a general journal line to a related voucher transaction.
Generally speaking there are two different ways how GL transactions created in D365FO: via Source document framework and via LedgerVoucherObject. Moreover, one transaction may be a result of summarization of multiple documents. So, this approach works for this particular scenario, when GL transactions come from a general journal. The proposed solution covers Ledger, Customer, Vendor, and Bank types. You can elaborate it for Project, Fixed Asset, etc. Check their appropriate classes.
LedgerJournalCheckPost class creates one transaction per a line of Ledger type, two if the latter has an offset info.
When it comes to other transaction type, first, a transaction in CustTrans, VendTrans, BankTrans etc is created, and then based on the latter a new transaction is added.
So, we creates the following extensions.
Below, you can find code snippets for each of them.
I wish to credit the following articles I used: