I am posting an invoice journal from AP/invoices/invoice journals. The posting is failing and after the fail it is showing the below messages in the infolog box
Invoice XXXXX was already used on date XXXXXX (warning yellow triangle
Invoice XXXXX was already used on date XXXXXX
Update has been canceled because of an error.
The first message displays twice as mentioned above and after that ‘Update has been canceled because of an error’
Here is the code snippet I am using to post the invoice and expecting to go into the catch if there was an error/warning
error(strFmt("An error occurred while posting the invoice journal for the JournalId: '%1'.", _ledgerJournalId));
err = MAHelperClass::infoCon2Str(infolog.infologData());
Any ideas how can I capture the errors and send it to the calling application?
Unfortunately I don’t see any description of any problem. Could you please tell us what doesn’t work?
For example, is the catch block executed and does ‘err’ variable get filled?
When I called the line of code LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable, NoYes::Yes).run(); it immediately posting the message in the info log and it doesn’t go into the catch statement in the above code snippet in my previous post but instead it throws the message in the info log.
I am expecting it to go into the Catch statement so I can grab the message and send it to the calling application. Does it help?
There may be several explanations:
- The process just puts messages to infolog but it doesn’t throw an exception. It don’t think that it’s the case, but if it was, you would simply collect infolog message after running posting and not in a catch block.
- An exception is throw, but you can’t catch it, because your code is inside a transaction. If it’s not obvious whether it is the case or not, check out TTS level in debugger.
- An exception is both thrown and caught, but you’re not aware of it, because you have a problem with debugging. Test that you can stop in debugger in the try block.
By the way, which version of AX it is about? It makes a difference - for example, if it’s AX 2012, you might also have a problem with CIL. When creating a new thread, please always attach a version tag (e.g. AX 2012).