Getting the class caller of the method for validation purpose

Hi All,

Need your help.

Is there a way on AX 2012 to get the class caller name of specific table method?

My scenario is I need to get the class caller name of update method of salesLine table and to put validations on specific class that are calling the updateMethod.

Thank you in advance guys.

You won’t get such a reference automatically - if you need it, you have to pass it to the method (or the object, if applicable) by yourself. But doing that in update() is something I consider wrong design. You should come up with more clever solution.

By the way, validateWrite() is usually a better place for validations than update().

Hi Chris,

If the Args is initialized prior to the execution of the update method, you can use args.caller to get the name of the caller (refer here), else you may refer to the stacktrace as given in the link.

And I agree with Martin over

HTH