web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Change file name of SS...
Finance forum

Change file name of SSRS when export to PDF using X++

(0) ShareShare
ReportReport
Posted on by 35

Hi all,

i am developing on D365FO, i want to set file name of SSRS when export to PDF.

I tried to use "this.parmReportRun().parmReportContract().parmReportCaption("Caption in Runtimes");" in prePromptModifyContract() method of  SrsReportRunController. But it was not worked.

After export to PDF, the file name of SSRS still be the label of Menu Item which call controller.

My code to set report caption:

protected void prePromptModifyContract()
{
super();
this.parmReportRun().parmReportContract().parmReportCaption("Caption in Runtimes");
}

Resutl is image below:

2019_2D00_08_2D00_13_5F00_12_2D00_20_2D00_24.png

Please tell me what i can do to change the file name with code x++.

Thanks

I have the same question (0)
  • Blue Wang Profile Picture
    on at
    RE: Change file name of SSRS when export to PDF using X++

    Hi Nguyen,

    Have you created a Controller class for your report and get any error?

    After that ,did you run the incremental CIL?

    You can refer to the defined classes in AOT.

  • Nishi Gupta Profile Picture
    206 on at
    RE: Change file name of SSRS when export to PDF using X++

    I am also facing this requiremnt  .. any solution ?

  • Suggested answer
    Sumit Loya Profile Picture
    2,230 on at
    RE: Change file name of SSRS when export to PDF using X++

    Try moving the code call to before super and check.

  • Suggested answer
    Martin Dráb Profile Picture
    236,960 Most Valuable Professional on at
    RE: Change file name of SSRS when export to PDF using X++

    I've made such a modification and it wasn't trivial. Here is my code:

    [ExtensionOf(classStr(SrsReportViewerControl))]
    final class My_SrsReportViewerControl_Extension
    {
        // We can't simply refer to the standard 'viewerContract' variable,
        // because it's private.
        private SrsReportDataContract currentViewerContract;
        
        public SrsReportDataContract parmViewerContract(SrsReportDataContract _viewerContract)
        {
            if (currentViewerContract != _viewerContract)
            {
                SysOperationDialog sysOperationDialog = Dialog::getDialogFromCaller(this.formRun()) as SysOperationDialog;
                if (sysOperationDialog)
                {
                    SrsReportRunController controller = sysOperationDialog.controller();
                    if (controller)
                    {
                        // Modifies the filename when exporting from report viewer control.
                        str filename = controller.my_getReportViewerExportFilename();
                        if (filename)
                        {
                            _viewerContract.parmReportCaption(filename);
                        }
                    }
                }
            }
            currentViewerContract = _viewerContract;
            return next parmViewerContract(_viewerContract);
        }
    }

    In my notes, I also have the following remark: It would have been simpler if a half of things in the report viewer wasn't private. :-)

  • Nishi Gupta Profile Picture
    206 on at
    RE: Change file name of SSRS when export to PDF using X++

    this worked perfectly , but now I facing another issue . the testing team seems to use embedded PDF viewer where my code fails . And putting the same code to the SrsReportPdfViewerControl extension does not help . any suggestions on that ?

  • Martin Dráb Profile Picture
    236,960 Most Valuable Professional on at
    RE: Change file name of SSRS when export to PDF using X++

    SrsReportPdfViewerControl determines the file name in exportViewerReport() method:

    str fileName = controller.parmDialogCaption() ? controller.parmDialogCaption() : controller.parmReportName();

  • Suggested answer
    Sharoze Khawar Profile Picture
    10 on at
    RE: Change file name of SSRS when export to PDF using X++

    You can change the PDF file name with any text through below code. I've replaced it with Invoice id. Read comments to replace it with any custom text

    [ExtensionOf(classStr(SrsReportRunController))]

    final class MySrsReportViewerControl_Extension

    {

       public LabelType parmDialogCaption(LabelType _dialogCaption)

       {

           LabelType           reportDialogCaption;

           Args                    args;

           CustInvoiceJour  custInvoiceJour;

           Name                  rdpName;

           reportDialogCaption = next parmDialogCaption(_dialogCaption);        

           if (this.getReportContract().parmRdpName() == 'Define your DP class name here')

           {

               args = this.parmArgs();

               custInvoiceJour = args.record();

               if(custInvoiceJour)

               {

                   reportDialogCaption = strFmt('%1', custInvoiceJour.InvoiceId); // Set the file name

               }

           }

           return reportDialogCaption;

       }

    }

  • Martin Dráb Profile Picture
    236,960 Most Valuable Professional on at
    RE: Change file name of SSRS when export to PDF using X++

    Your code contains extra line spaces because you didn't paste in the right way. Please use Insert > Code in the rich-formatting view.

  • SukhvirSingh Profile Picture
    10 on at
    RE: Change file name of SSRS when export to PDF using X++

    I tried above code but it is not calling this method? Any suggestion

  • SukhvirSingh Profile Picture
    10 on at
    RE: Change file name of SSRS when export to PDF using X++

    I have tried this code but the method mentioned is not called.

    Any other suggesion please

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans