Monday, January 20, 2020

Error message in AX/D365 : Remove prefix in error message

In AX, prefix mechanism is used for precise error messaging about the transactions that an application performs. If required for your customization you do not wish to show the prefix text in error message we can achieve that using following :

This code will show error with prefix text :
throw error("Customer not found");
Output will be : 
someprefixedtext + Customer not found

This code will suppress prefix text :
throw infolog.add(Exception::Error, "Customer not found");
Output will be : 
Customer not found

All this happens in classmethod : Global\error.
infolog is global variable.


How to loop selected records on grid for form in dynamics ax?

To loop/iterate selected records from grid on form you can use following code, this can be done on clicked method of button control : Invent...