Thursday, May 6, 2021

Dynamic SSRS report name in D365 FnO

 When there is a requirement to generate dynamic report name. For example when saving report, the report name should be appended with Customer ID, Invoice ID etc. To do this in the controller class we have to write code for parmDialogCaption() method shown below:-

 

class DemoController extends SrsReportRunController
{
 
    public void prePromptModifyContract()
    {
        ProjInvoiceJour              projInvoiceJour;
        DemoContract             contract;
        FormDataSource               fds;
        
        contract    = this.parmReportContract().parmRdpContract() as DemoController;
        projInvoiceJour = args.record();
        fds = args.record().dataSource();
        contract.parmProjInvoiceId(projInvoiceJour.ProjInvoiceId);  
    }

    public static client void main(Args args)
    {
        DemoController             demoController;
        ProjInvoiceJour              projInvoiceJour;
        demoController= new DemoController();
        demoController.parmArgs(args);
        demoController.parmReportName(ssrsReportStr(RAR_AmazonBillingReport, Report));
        demoController.parmShowDialog(false);
       
        demoController.parmReportContract().parmReportCaption("Project Invoice Report");
        
        projInvoiceJour = args.record();
        demoController.parmDialogCaption("Project Invoice Report" + "_"+ projInvoiceJour.ProjInvoiceId); // This will generate dynamic report name        
        demoController.startOperation();
    }


when you export the report in excel, pdf or csv, the report name will be appended with ProjInvoiceId.

using SQL Query in X++

 If you need to execute sql query inside your X++ code then below example can help you. To pass value to SQL query we need to use strfmt() f...