web
You’re offline. This is a read only version of the page.
close
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 172

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();
    }

I have the same question (0)
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Doing such a thing in a data provider is indeed wrong.

    You're also using a completely wrong contract. PSAProjInvoiceDP report uses PSAProjInvoiceContract, not SysUserLicenseCountRDPContract. It also has a specialized controller, PsaProjAndContractInvoiceController, with a plenty of business logic that you're currently skipping.

    If you tell us more about your business requirement, we should be able to help you design a meaningful solution.

  • RadekM Profile Picture
    172 on at

    Indeed first of it I tried it in a extended class:

    class ProjInvoiceControllerSZM extends PSAProjAndContractInvoiceController

    Actually my goal is to change pdf name of project invoice (and in future sales invoice) so it refeer to invoice number.

    It's confusing it all my invoices have the same name. So when I view a invoice I can export it to pdf or save it as pdf (based on local dev version where my report first is generated on screen and onpremise where it run as pdf) later on this need to work on cloud.

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    In which cases you want to change the name? You last paragraph mentions an export from the report viewer form, but it has nothing to do with your code, where you're trying to run a report in batch and generate a file.

    Your last sentence sounds like all you need it to enable the new report viewer experience in your cloud environment. See Preview PDF documents using a PDF viewer for details.

  • RadekM Profile Picture
    172 on at

    I go to - Project management and accounting > Project invoices > select any invoce and press print > when I want to save the generated pdf file I want to have the invoice number not 'show invoice' or 'show invoice - finanse and operations' depending if i press print to pdf or download pdf

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    It'll display the report to screen and then you want to save it, right? If so, forget all the code above, because it's not related to what you want.

    Do you want to get this working with the embedded PDF viewer (mentioned in my last reply) only or do you need to support the old HTML-based preview as well? I built a solution for the old viewer in the past, but I would avoid it these days when the embedded PDF viewer is taking over.

  • RadekM Profile Picture
    172 on at

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

  • Suggested answer
    Rahul Mohta Profile Picture
    21,032 on at

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

    pls review and suggest

  • Suggested answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    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.

  • RadekM Profile Picture
    172 on at

    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..

  • RadekM Profile Picture
    172 on at

    @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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans