To get the caller class name.

Hi All,

How to get the caller class name. I would like to do validation basing on the caller class name please suggest me the way to get caller class name.

Thanks in advance.

Hi giridhar,

you can use element.args().caller(), this will work for your condition to check the caller class

Trish!

Hi Trishanth,

Thanks for your reply. You asked me to use element.args().caller() right?? But, the element is used for form rite?? The above scenario works only in the case of a form and class but not between two classes i think so. In my scenario there are 2 classes where one class method is being called in another class. I want to get caller class name in the second class.Does element.args().caller() in my case. If it works can you please explain me the scenario with an example.

Thank you…

Don’t be surprised by answer you didn’t want, if you don’t provide enough information.

Calling class don’t know how it was called unless you provide a reference to the caller object. The most straightforward way is let the caller class to pass itself as method parameter - e.g. method(this).

Rather then working with class names, you should use is operator (in AX2012) or SysDictClass::is() in older versions. It will ensure that your code works for child classes as well and it allows you to use interfaces (e.g. _caller is SysRunable).