Capturing infolog messages in AX 2012

Description:-

Today I am going to explain how to capture infolog messages for a particular record and show those logs on click of a log button on a form.

1) Create a job which inserts records into a table, prints some info messages and capture them.

logTable contains three fields name and infolog. info is a field created with EDT infologData and visible property is set to NO. info is a container which stores the infolog messages for the particular record.

Example:-

static void TestJob(Args _args)
{
    InfoLogStatusTable       insertLog;
    InfologData  msg;
 
    ttsbegin;
    insertLog.initValue();
    insertLog.Name= "Umesh";
    //info(strFmt("%1", insertLog.Infolog));
 
    //info(strFmt("Entered Name :- %1", insertLog.Name));
    info(strFmt("name %1 created successfully", insertLog.Name));
 
    msg        =    infolog.infologData();
    insertLog.Infolog           =   msg;
    insertLog.insert();
    infolog.import(msg);
   
    ttscommit;
}

NOTE :-
i) Save compile and run this job. name is hard coded. These two values are inserted into table.
ii) The info stored for this record are :

name Umesh created successfully

2)  Now create a form with grid showing the logTable datasource fields and button named log.
Write the following code in clicked method of the button

void clicked()
{
    InfologData  msg;

    msg = InfoLogStatusTable.Infolog;
    infolog.import(msg);
}

Now when you select this particular record and press the log button the infolog messages stored for this record are displayed in info.

Related Posts

Previous
Next Post »

1 comments:

comments

Thanks for comments.....