Running an SSRS report from the selected record in D365FO


SSRS reports are used to display data in an organized way. It helps the users to get the data as per their own business formats and scenarios. In Microsoft Dynamics 365 for Finance and Operations or in Microsoft Dynamics AX 2012, SSRS reports play a vital role for the users. Without this, business applications are incomplete. Moreover, running an SSRS report from the selected record of a form is very commonly required by the users.

In my this tutorial, I will show you how to run an SSRS report from the selected record in a form in Microsoft D365FO and in Microsoft DAX2012. It is very helpful as this is very common requirement.

Let’s start!

I am creating a new report from scratch. I am using the Microsoft D365FO environment for the development of the report from scratch. For example, I am creating a Purchase order report.

After completing all the steps below to create SSRS report in D365FO, you would have the following elements in your project:

  • RDP Class
  • Controller Class
  • Contract Class
  • Temporary tables
  • Report
  • Output menu item
  • Form extension

After that, you have to override a function of controller class. Just copy and paste the following function in the controller class:

protected void prePromptModifyContract()
{
     PurchaseOrderContract contract = this.parmReportContract().parmRdpContract() as PurchaseOrderContract;
     if(this.parmArgs().dataset() == tableNum(PurchTable))
     {
          PurchTable purchTable = this.parmArgs().record() as PurchTable;
          contract.parmPurchId(purchTable.PurchId);     
     }
}

I have already mentioned the properties of the Output Menu Item and the form’s Menu Item Button in Create SSRS report in D365FO. But, because it is too much important, so I am mentioning them again below:

Set the properties of output menu item as follows:

  • Object: PurchaseOrderController
  • Object Type: Class
  • Subscriber access level: Unset
  • Needs Record: Yes

Create an extension of form in which you want to show the output menu item. In this scenario, you should add the button where the Main Data Source table is PurchTable. As, we are fetching the record from the form using the prePromptModifyContract() function.

We have created the Purchase Order Report with the Purchase Order Number (PurchId) as the parameter. So, we should use the PurchTable form.

So, create extension of the form by right-clicking the PurchTable in AOT->User Interface->Forms. Then click the Create extension. In the project, an extension of the PurchTable form would be created. In the form, create Menu Item Button and set the properties as follows:

  • Data Source: PurchTable
  • Needs Record: Yes
  • Menu Item Name: Name of OutputMenuItem
  • Menu Item Type: Output

Note: Needs Record and Data Source properties are only required if you are running an SSRS report from the selected record of a form. Otherwise, it’s not mandatory.

Comments