≡ Menu




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.

Exceptions

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;

 

try

{

aifInfoLog = new AifInfoLog();

result = test / ab;

 

 

}

catch

{

infologData = aifInfoLog.getInfoLogData();

infoLogEnum = SysInfoLogEnumerator::newData(infologData);

while(infoLogEnum.moveNext())

{

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

_Excep.insert();

 

 

}

 

}

 

Sysexceptiontable

 

 

{ 0 comments… add one }

Leave a Comment