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”;












Ali Raza Zaidi, Microsoft ERP Consultant, Currently working for Business Experts Gulf in United Arab Emirates. Specialized in HR & Payroll, Supply Chain and Financials modules.