capture the infolog content and save in file directory.

Hi everyone,

I am trying to capture the infolog content(Error message) during the creation of sales order and I want to save this content message in file directory(eg:in pdf format). How can I proceed it. Please help me regarding this.

I got one link, they are telling to change the configuration; https://community.dynamics.com/ax/b/axfaqblog/archive/2015/09/17/save-infolog-messages-using-listeners

but I am not able to get, where the file will be save and how; And what i have to do for that. So, please guide me.

Thanks

Mani.

Hi mani,

Can you please where you are struck in?

The link is about tracing, which would capture all messages, not just “during the creation of sales order”, therefore I’m not sure if it’s useful for you. By default, the file would be saved in the folder where is the application (which is ax32.exe in the blog post).

If you want to do it in code, you can use infolog object to get the infolog data. How you can save the file depends on which format you choose. Note that saving text files is much easier than creating PDF documents.

Thank you,

I got about above link now. But, I need to capture only during the sales order and it should be save in pdf format in any particular file directory.As you told to use infolog object to get the infolog data, I tried it but I am not able to find it. please help me.

Thanks Mani.

First of all, you’ll need to know which lines in infolog are related to your process, therefore call infologLine() at the beginning and remember the value. When you’re done, take all lines after that one and call infologLine() to get the upper limit. If you logged everything, you would get messages that were there even before starting the process and therefore unrelated to your problem.

Then you can call infolog.text(), infolog.level() etc. to get details (you’ll always pass a line number there).

Alternatively you can call copy() or cut() to get all the data at once and store it in a container field or pass it to another method for processing.

Hello Martin,

This is what ,I am doing…

Actually I am creating one sales order inside that in the line part I left one field,to get error and to track this error;I putted the break point in ‘info’ class -add method and i got stack trace error, below is the screen shot of my stack trace error ; where i got that From the InventonHandQty class checkitemdraw method I am getting this error.

Now, I want this error(That is verifed with the label code for the same error) to capture and save in one table’s string field. For that I wrote this code to save in table’s field:[tableForError is my table buffer and GotError is my field(str-data type)]

ttsBegin;
tableForError.GotError = strFmt("%1","@SYS2176");
tableForError.insert();
ttsCommit;

Stack Trace Error:-

Here, I putted the code to save the error in table’s field:(inventonHandQty-class, checkItemDraw-method)

public boolean checkItemDraw(
InventQty _inventQty,
NoYes _negativePhysical,
boolean _addInfo = true,
PdsCWInventQty _cwQty = 0
)
{
InventSumDelta inventSumDelta;
InventQty availPhysPost;
InventQty availPhysDelta;
str inventDimCriteriaPrefix;
Error_JJ errorjjj;
TableForError tableForError;//
str Error;

PdsCWInventQty cwAvailPhysPost;
PdsCWInventQty cwAvailPhysDelta;

if (! _negativePhysical)
{
// If WHS item, perform different check
if (itemUsesWHS)
{
return this.whsCheckItemDraw(_inventQty, _addInfo);
}

if
(!cwItem && (this.availPhysical() < (-_inventQty))
|| (cwItem && (this.pdsCWAvailPhysical() < -_cwQty)))
{
if (! _addInfo)
{
return false;
}

setPrefix("@SYS70390");
inventDimCriteriaPrefix = inventDimCriteria.preFix();

if (inventDimCriteriaPrefix)
{
setPrefix(inventDimCriteriaPrefix);
}

if (!appl.inventUpdateOnhandGlobal().inventUpdateOnhand().isFinalCommit())
{
if (cwItem)
{
return checkFailed(strFmt("@PDS87", -_cwQty, this.pdsCWAvailPhysical()));
}

ttsBegin;
tableForError.GotError = strFmt("%1","@SYS2176");
tableForError.insert();
ttsCommit;

return checkFailed(strFmt("@SYS2176", -_inventQty,this.availPhysical()));

}
else
{
availPhysPost = this.availPhysical();

if (cwItem)
{
cwAvailPhysPost = this.pdsCWAvailPhysical();
}

inventSumDelta = this.findSumJoinDelta();
inventSum.clear();
inventSum.addInventSumDeltaQty(inventSumDelta);
inventSum.addInventSumDeltaValues(inventSumDelta);
availPhysDelta = this.availPhysical();

if (cwItem)
{
cwAvailPhysDelta = this.pdsCWAvailPhysical();
return checkFailed(strFmt("@PDS87", -cwAvailPhysDelta, cwAvailPhysPost-cwAvailPhysDelta));
}

return checkFailed(strFmt("@SYS2176",-availPhysDelta,availPhysPost-availPhysDelta));
}
}
}
return true;
}

So, Overall its compiling successfully; But its not inserting in the table field ie. error message. where I am doing wrong or whether it is good way or not.Please guide me.

Thanks

Mani.

This is a completely different thing. You said you wanted to capture infolog messages and that’s what I explained to you. But your code doesn’t do it at all! You never look at infolog messages, you have a piece of code writing something to a table, independently on infolog messages. Can you please confirm that you don’t want to capture infolog messages anymore?
The problem with your code is that it’s inside a transaction and when an error occurs, all database changes are rolled back. This applies to your inserts to TableForError too.
You could use a separate DB connection for these inserts, but if your requirements is to capture all infolog messages, adding your code to every place where a message may be written to infolog isn’t feasible. You should capture infolog messages thrown at a single place, as discussed above.