Thursday, March 24, 2022

D365 Running an SSRS report from the selected record X++

 

All the steps are mentioned in the article: Create SSRS report .

After completing all the steps of the article , 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 . 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.

Also, see the article about how to Create SSRS report and how to Customize SSRS report using extension and D365 Running an SSRS report from the selected record.








No comments:

Post a Comment