Passing Parameters to a Report in Dynamics AX

Creating reports in AX is generally ‘a walk in the park’ even for the new developers not fully acquaint with the syntax of X++. However, it sometimes becomes challenging to understand how the parameters could be passed to a report when you want to initiate that report from a form.

Let’s look at an example where you may want to create a ‘Purchase Requisition Report’ that the users could generate to see the status of each purchase requisition and the associated workflow entries for that Purchase Requisition.
I will not go into the details of how to develop this report, but you should know that such a report do not exist in the out-of-the-box functionality within AX 2009.
So let’s say that you have developed this report and now when you generate this report you can pass on the required ‘Purchase Requisition ID’ in the ‘Parameter Prompt’ of the report to view the particular PR details accordingly.
However, now in the next step you want to call this report from the ‘Purchase Requisition’ Form (PurchReqTable).
To do this, you should first create a ‘Button’ within the Button Group in the Form.
Now right-click on the ‘Methods’ node within the newly created button and choose ‘Override Method –> clicked’
Within the clicked function, you should write the following code;
void clicked()
Args args = new args();
ReportRun reportRun;
reportRun = classFactory.reportRunClass(args);
The above code calls the ARGS system class. This class is used to pass arguments to a class-constructor. You pass information such as name, caller and parameters to a ARGS class. This code passes the relevant Purchase Requisition ID (which is currently selected by the user on the form) to the report ‘PurchRequisitionDetails
Now, you need to go to the Form (which in this case is PurchReqTable).
Right-Click on the methods node of the Form and click on Override Method –> init()
In this init() method, you need to enter the following code to allow the report to read the parameters from the form.
public void init()
.addRange(fieldnum(PurchReqTable, PurchReqId)).value(element.args().parm());
info(“Error in init method”);
You should now be able to generate your report directly from the form with required parameters.

2 responses

  1. Hi Raziq,

    where can i find the report to override the init method as you mention:
    Right-Click on the methods node of the Report and click on ‘Override Method –> init’


    1. Hello, Sorry for misguiding you.

      It is not init method of Query, it is init method of Form. I corrected it.

      Thank you and keep going.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: