With every customization we make to Dynamics AX (2012), we should first try to find a way to solve the requirement with standard AX. But when there is the need to customize it, we should also try to use as much standard functionality as possible to not reinvent the wheel.

During development we quite often write little helper methods. There is a neat class called AifUtil that many people don't know about. This class has some useful functions.

A very common example is catching CLR Exceptions. I know so many developers that write a function to catch the last CLR Exception by themselves. Taking a look at the class AifUtil, we see a method called getClrErrorMessage() that does exactly that for us!

Also to catch other errors not only within an AIF context, we can use the class AifInfoLog.
Here is an example to demonstrate the usage. Just set a debugger to view the content of the variable message.

    AifInfoLog aifInfoLog;
str        message;

aifInfoLog = new AifInfoLog();

warning("This is a warning");
error("This is an error");
info("This is an info");

message    = aifInfoLog.getLastMessage();
message    = aifInfoLog.getLastErrorMessage();

### Subscribe to robsCode

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!