The Ax Infolog

May 7, 2010 No comment

Wel all know the small dialog that gives the user usefull information about what is happening in Ax. In this post I will tell u some more about this.

You can add information to the Infolog by calling:



The info(), warning() and error() method are found in the Global class and can contain up to 3 arguments:

1
2
3
4
SysInfoAction   sysInfoAction;
;
sysInfoAction = SysInfoAction_Formrun::newFormname(formstr(HRMParameters));
info("click on me", "", sysInfoAction);



Using the keyword Throw before info(), error() or warning will result in terminating the execution (or jump to catch statement) and a rollback of your transactions.

1
throw error("Something bad happend");



The method setPrefix() will help you to group info(), warning() and error() messages with a header. using setPrefix() will make a indentation for your current block of code (everything between { and }). Leaving the code-block will automatically result in going one indentation back.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int i;
int j;
;
setPrefix("Testing out setPrefix");
 
for (i=1 ; i<=2 ; i++)
{
	setPrefix(strfmt("Prefix %1", i));
 
	for (j=1 ; j<=3 ; j++)
	{
		info(strfmt("Info %1", j));
	}
}



The checkFailed() method is a warning() method that returns a Boolean (alwais false). U can use this method when you want to display a warning and directly set a return value to false.

1
2
3
4
5
6
7
Boolean ret;
;
if (true)
{
    ret = checkFailed("Something is wrong");
}
return ret;



Note: The infolog can contain maximum 10000 lines. So try to limit the use of it. Building the output of the infolog usually happens at the end of the code you are executing and depending on the number of lines, it can take a while. You can limit the maximum number of lines under a header in a batch by setting the property infolog.errorsPerBatch(#)(). When this number is exceeded only the furst # will appear and Ax will give you a notification that their could be more errors.
It is also possible to update the infolog while executing code by calling the method infolog.viewUpdate().

Using the infolog in the Enterprise Portal:
In the portal you can access the infolog by using the Proxy of the Enterprise Portal.

1
2
using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;
Proxy.Info objInfoLog = new Proxy.Info(this.AxSession.AxaptaAdapter);

Now, when you want to write something to the infolog you need to give a Enum with it, so the portal knows if the message you want to show is a info, warning or error. So pass through Proxy.Exception.Info, Proxy.Exception.Warning or Proxy.Exception.Error.

1
objInfoLog.add(Proxy.Exception.Warning, "My warning");

So in short thing you should keep in mind while using the Infolog-class: