Posts

Showing posts with the label caller

What is the parmLastActivatedForm method used for in Dynamics AX?

Image
Hello readers, In my earlier post, we had seen how to get all of a form's callers in Dynamics AX . One of my readers brought up a very good and interesting question around this. Some action forms opened like the Document handling form will not show the caller. Is there a way to find the caller for these forms? This is indeed correct. If you open the document handling form from any form, and look for the caller name, it will be empty. See the below image to understand what I mean. Well, this shouldn't stop us Dynamics AX developers from getting our way. In this post we will learn how to get the caller in such scenarios. The answer lies in a method in the Info class - parmLastActivatedForm() Basically, the parmLastActivatedForm() method returns the last form that was activated. So let us see all this in action. My code is in Dynamics AX 2012, but you can easily apply it in Dynamics AX 2009 as well. Let us modify the init() method of the DocuView form. This is...

How to get Form's caller in Dynamics AX?

Image
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; ...