Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Ledger journal validation error catch and store using X++

Posted on by 22
Hi experts,
 
I am working on ledger journal validation. I want to store validation error into one of the table.
I have wrote following code to catch validation error but unable to catch validation error and following
code showing the standard error message where as I want to catch and store validation error.
 
I am getting following validation error message but requirment to catch and store error
 
Code:
public class TestClass
{
    public static void main(args _args)
    {
        LedgerJournalTable  ledgerJournalTable;
        LedgerJournalCheckPost  ledgerJournalCheckPost;
        SysInfoLogEnumerator infoLogEnum;
        SysInfologMessageStruct infoMessageStruct;
        str integrationMessage;
        LedgerJournalTable = LedgerJournalTable::find('JB2551921');
        try
        {
            ledgerJournalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable, NoYes::no);
           // ledgerJournalCheckPost.run();
            LedgerJournalCheckPost::processOperation(ledgerJournalCheckPost);
        }
        catch(Exception::Error)
        {
            info('Catch');
            infoLogEnum = SysInfoLogEnumerator::newData(infolog.infologData());
            while(infoLogEnum.moveNext())
            {
                infoMessageStruct = SysInfologMessageStruct::construct(infoLogEnum.currentMessage());
                integrationMessage = integrationMessage + infoMessageStruct.message() + '/';
                info(strfmt('Error message of failure is %1',integrationMessage));
            }
        }
    }
}

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans