I am creating and posting Dynamics AX Ledger Journals from C#.
I want to use the two helper classes the come with AX,
LedgerJournalEngine and LedgerJournalCheckPost, to validate the journals I create.
My questions are:
1.) How do you get a list of errors -> voucher from either of these classes or some other class?
2.) Can you simulate a post inside of a AX transaction and roll it back?
2-a.) If you roll back a posting in a transaction will AX be smart enough to reuse the voucher numbers that got rolled back?
I ended up with:
Have you considered using AIF?
The easy way if you insist on calling AX directly:
Create static X++ methods and call these:
infolog
(as a string)Let the AX methods do the plumbing with the ledger posting classes.
The posting is all or nothing (with possible transfer of error lines to a new journal). Voucher numbers are reused in case of error. This implies, I guess, that voucher numbers are allocated on posting, which can be set up on the journal name.
The
infolog
return value could be converted to a string to simplify the C# side.X++ code to convert to string:
The way to call it: