X++ code to fetch the system errors
Description :- This class will help you to fetch the error which occurs in system while doing any operation in D365FO
class BASMSGetErrorMsgJob
{
/// <summary>
/// Class entry point. The system will call this method when a designated menu
/// is selected or when execution starts and this class is set as the startup class.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
SysInfoLogEnumerator infoLogEnum;
SysInfologMessageStruct infoMessageStruct;
List errorList = new List(Types::String);
try
{
//Logic
}
catch(Exception::Error)
{
infoLogEnum = SysInfoLogEnumerator::newData(infolog.infologData());
while(infoLogEnum.moveNext())
{
infoMessageStruct = SysInfologMessageStruct::construct(infoLogEnum.currentMessage());
str integrationMessage = infoMessageStruct.message();
errorList.addEnd(integrationMessage);
}
}
}
}