Friday, January 6, 2023

Capture all Error logs trace in D365FO

    [SubscribesTo(classStr(Info), delegateStr(Info, onInfoLogMessageAdd))]

    public static void Info_onInfoLogMessageAdd(InfoLogMessageAddEventArgs _eventArgs)

    {

        SANPOCDebugTable    sanPOCDebugTable; (Enable with CreatedDateTime)

        boolean                      iscallStackUserEnabled;

            iscallStackUserEnabled = true;//Added custom checkbox on custom user setting

                   if(_eventArgs.exception == Exception::Info || 

                           _eventArgs.exception == Exception::Warning)

                    {

                        //If want to skip validation
                    }

                  else

                {

                sanPOCDebugTable.clear();

                sanPOCDebugTable.initValue();

                sanPOCDebugTable.RunByuserId = curuserid();

                sanPOCDebugTable.Exception = _eventArgs.exception;

                sanPOCDebugTable.InfologStr = _eventArgs.message;

                sanPOCDebugTable.CallStack = xSession::xppCallStack();

                sanPOCDebugTable.insert();

                }

}

//Create new form and add table on it -> Add button to import log information

//To Clean up -> Create batch run -> run to clean up data for past 90 days

//To add this new log form -> generic to all form UI. (To review logs)

Ref: Blog on Microsoft Dynamics AX/ D365: To add dynamics default controls on UI in D365FO (sangeethwiki.blogspot.com)

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...