web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Ledger journal validation error catch and store using X++

(0) ShareShare
ReportReport
Posted on by
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));
            }
        }
    }
}
I have the same question (0)
  • Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at
    Ledger journals already stores messages in a database: LedgerJournalTable.Log field. Can't you use that?
  • CU03061214-0 Profile Picture
    on at
    Thanks export.
     
    LedgerJournalTable.Log stores the validation error but this field doesn't store full validation error because this field length are 255 char.
    Kindly advice the solution which can store full validation error message.
     
    Many thanks in advance.
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    You can create a log table with fields, Journalid, error message and error created date time (if required) and get the error into a list and pass the list to the log table.
  • Verified answer
    Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at
    One option is extending LogText EFT and increasing the length. Another approach is adding custom logic in a extension of LedgerJournalCheckPost.updateTableInfoLog(). You can also take log entries collected in LedgerJournalCheckPostResults and save them to your table. Use ledgerJournalCheckPost.parmPostingResults() to get the results object.
  • Verified answer
    Kevin Xia Profile Picture
    Microsoft Employee on at
    Hi,
    As Martin said, there are many ways to achieve your goals, depending on your needs or business scenario. If you just need to store the complete error message, you can increase the length of the field so that it can accommodate the complete error message. If there are more complex requirements or business scenarios, you can consider creating a new table to store error information.
    Best regards,
    Kevin
  • Kevin Xia Profile Picture
    Microsoft Employee on at
    Hi,
    Has your problem been solved? If so, you can mark the thread as verified so that other users of the forum can view the post.
    Best regards,
    Kevin

Under review

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

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans