How to get Form's caller in Dynamics AX?
Hello readers, In Dynamics AX, when we need to find the parent of a form, we call the caller() method on the args object of the formRun object of the form. The syntax is, FormRun callerForm = element.args().caller(); In the same way, we can find the parent of the caller form as well. Something like, FormRun callerForm = element.args().caller().args().caller(); Try that and Dynamics AX will throw an error that " The variable is not of the type CLASS. " We can call only upto the 3rd method after which the AX compiler fails to return an object. We will have to first store the args() object in a seperate variable and then call the caller() method. Let us look at an example of getting all the ancestors for a form. I've a simple form, with just two methods - init() and parmFormName() Declare a variable formName of type Name in the classDeclaration. public Name parmFormName(Name _formName = formName)
{
formName = _formName;
return formName;
...