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:
- Infolog.add(…)
- info(…)
- warning(…) or checkfailed(…)
- error(…)
- You can add some structure in it by using setPrefix(…)
- Using the Proxy-class for the Enterprise Portal
The info(), warning() and error() method are found in the Global class and can contain up to 3 arguments:
- a string (mandatory) : the string that is added to the infolog
- a path to the Axapta Help (optional)
- an Infolog action (optional) : you can use this parameter to initiate a action, for example open the code editor or open a parameter-form when some parameters are missing. Depending on what action you want to trigger, you need to call the right method that extend from sysInfoAction.
1234 |
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.
1234567891011121314 |
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.
1234567 |
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.
12 |
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:
- Use short & informative messages
- Choose the righty message level (info, warning, error)
- Use actions, this simple trick is verry usefull for end-users
- Limit the number of messages you send to the Infolog-dialog