Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Change pdf file name for invoice

(0) ShareShare
ReportReport
Posted on by 88

Hello,

I try to change the file name for pdf invoices. I tried with printsettings but names are not changes still all files are 'show invoice'

Im using D365 FO. I put it in DP_EXT, maybe I should do it somewhere else ? WHen i put it into controller class report dont generate.

[ExtensionOf(classStr(PSAProjInvoiceDP))]
final class PSAProjinvoiceDP_Extension
{
    public static void main(Args _args)
    {
        SrsReportRunController          controller = new SrsReportRunController();
        SysUserLicenseCountRDPContract  rdpContract = new SysUserLicenseCountRDPContract();
        SRSPrintDestinationSettings     settings;
 
        // Define report and report design to use
        controller.parmReportName(ssrsReportStr(PSAProjInvoiceSZM, PrecisionDesign1));
        // Use execution mode appropriate to your situation
        controller.parmExecutionMode(SysOperationExecutionMode::ScheduledBatch);
        // Suppress report dialog
        controller.parmShowDialog(false);
 
        // Explicitly provide all required parameters
        rdpContract.parmReportStateDate(systemDateGet());
        controller.parmReportContract().parmRdpContract(rdpContract);
 
        // Change print settings as needed
        settings = controller.parmReportContract().parmPrintSettings();
        settings.printMediumType(SRSPrintMediumType::File);
        settings.fileFormat(SRSReportFileFormat::PDF);
        settings.fileName('Invoice.pdf');
 
        // Execute the report
        controller.startOperation();
    }

  • Martin Dráb Profile Picture
    233,013 Most Valuable Professional on at
    RE: Change pdf file name for invoice

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

  • Suggested answer
    Sharoze Khawar Profile Picture
    10 on at
    RE: Change pdf file name for invoice

    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;

      }

    }

  • RadekM Profile Picture
    88 on at
    RE: Change pdf file name for invoice

    Check on which Output your controller runs.

    Also this is working for me.

    Rembember setting parmLoadFromSysLastValue to false or the dialog will be used from Cache and repeat over and over as your filename.

            formlettercontroller.parmLoadFromSysLastValue(false);
            formLetterController.parmShowDialog(false);
    
            if (custInvoiceJour.isProforma())
            {
                formLetterController.parmDialogCaption("Proform for invoice "   custInvoiceJour.Salesid);
            }
            else
            {
                formLetterController.parmDialogCaption("Invoice Num "   custInvoiceJour.InvoiceId);
            }
    
            formLetterController.startOperation();

  • Martin Dráb Profile Picture
    233,013 Most Valuable Professional on at
    RE: Change pdf file name for invoice

    I provided actual code in another thread: Change file name of SSRS when export to PDF using X++.

    Just let me repeat what I said above. It's a solution for the old report viewer, not the embedded PDF viewer.

  • Nishi Gupta Profile Picture
    204 on at
    RE: Change pdf file name for invoice

    I am setting the parmReportCaption()  ,it shows on the dialog but when exported to PDF it again goes and takes the default name.

  • RadekM Profile Picture
    88 on at
    RE: Change pdf file name for invoice

    @Martin Dráb i found one of your answers for sales invoice. Could youe please say me where is the right place for it so it not colides with printmgmtsetting ?

    This is how it's normally done:
    
    SRSPrintDestinationSettings settings = controller.parmReportContract().parmPrintSettings();
    settings.printMediumType(SRSPrintMediumType::File);
    settings.fileFormat(SRSReportFileFormat::PDF);
    settings.fileName('the file name you want');
    Note that sales invoice uses print management, therefore make sure you apply your parameters after loading print management setup, otherwise it would be overwritten.

  • RadekM Profile Picture
    88 on at
    RE: Change pdf file name for invoice

    I went back to this problem and tried to change these valuues but no reaction I can't find the right place/ time to change it..

  • Suggested answer
    Martin Dráb Profile Picture
    233,013 Most Valuable Professional on at
    RE: Change pdf file name for invoice

    The name is determined in SrsReportPdfViewerForm.getPdfFileName(). If you look inside, you'll see that it takes either controller.parmDialogCaption() (if set) or controller.parmReportName()). Therefore you can influence the file name by changing these values at the right time.

  • Suggested answer
    Rahul Mohta Profile Picture
    21,014 on at
    RE: Change pdf file name for invoice

    we have used an ISV Doccentric and it does good in this scenario

    pls review and suggest

  • RadekM Profile Picture
    88 on at
    RE: Change pdf file name for invoice

    Then I should use the embedded PDF view. We will anyway run on cloud in 2-3 months

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,013 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans