How to get exception detail and log into SysExpectionTable. Dynamics Ax 2012

When we are working with Document Aif services, any exception is logged in SysExceptionTable. You can excess these details from following link.


There is client requirement that all exception must be log in SysExceptiontable in custom service. I did this with the help of following code snippets which just log the division by Zero exception in SysExceptionTable.



static void Job19(Args _args)



InfologData         infoData;

AifInfoLog          aifInfoLog;

container           infologData;

SysInfoLogEnumerator            infoLogEnum;

SysInfologMessageStruct         infoMessageStruct;


SysExceptiontable _Excep;

str  ExceptionMessage;

int ab=0;

int test=10;

int result;




aifInfoLog = new AifInfoLog();

result = test / ab;






infologData = aifInfoLog.getInfoLogData();

infoLogEnum = SysInfoLogEnumerator::newData(infologData);



//Extract the message from the string

infoMessageStruct = SysInfologMessageStruct::construct(infoLogEnum.currentMessage());

ExceptionMessage +=”\n” + infoMessageStruct.message();




_Excep.Exception =Exception::Error;

_Excep.Description = ExceptionMessage;

_Excep.Module =”Mamoo’s Test”;












Advisory software engineer, Software engineer, Last 4 years focus on Dynamics Ax 2012. MVP and Microsoft Certified trainer for Dynamics AX.