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 :
Small and medium business | Business Central, N...
Suggested answer

How to change the name of downloaded PDF?

(1) ShareShare
ReportReport
Posted on by

Hi all,

I have a concern that when I download report from BC, the report always named after the report name.

pastedimage1615436405615v1.png

For example, I will have Sales - Shipment (1), Sales - Shipment (2), Sales - Shipment (3) and etc.. And my teams spend a lot time to renaming them in their device after downloading the file. If there any ways I can customize the PDF file naming right after downloading from BC? I would like to have the names, for instance, Sales - Shipment_(Posted Sales Shipment."No.").

Thanks in advance!

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    121 on at
    RE: How to change the name of downloaded PDF?

    You could look at the report selections table and subscribing to OnBeforeSaveReportAsPDF. Worth considering if you choose email it adds the document no. to the file name, which I assume is what you want. If it cannot email it will download the file anyway. It may put the document number in that way

  • Suggested answer
    Hein Kruger Profile Picture
    629 on at
    RE: How to change the name of downloaded PDF?

    Hi ,

    From BC21 there is a event subscriber that allows you to change the Filename from base app Report Selection per report.

    In Code unit “Custom Layout Reporting” we can use the eventsubscriber “OnGenerateFileNameOnAfterAssignFileName” to change the File name. The Code will look something like this. In my case I wanted to change the customer Statement File Name.

    [EventSubscriber(ObjectType::Codeunit, Codeunit::”Custom Layout Reporting”, ‘OnGenerateFileNameOnAfterAssignFileName’, ”, true, true)]

    local procedure OnGenerateFileNameOnAfterAssignFileName(var FileName: Text; ReportID: Integer; Extension: Text; DataRecRef: RecordRef)

    var

    Customer: Record Customer;

    FileNameDate: Text[20];

    dotpdfPos: Integer;

    PreFileNameLbl: Label ‘Statement for %1 %2 %3’;

    Pos: Integer;

    LengthText: Integer;

    begin

    if ReportID = 1316 then begin

    Customer.Get(DataRecRef.RecordId);

    Pos := Text.StrPos(FileName, ‘as’);

    dotpdfPos := Text.StrPos(FileName, ‘.pdf’);

    FileNameDate := Text.CopyStr(FileName, Pos, dotpdfPos);

    FileName := StrSubstNo(PreFileNameLbl, Customer.”No.”, Customer.Name, FileNameDate);

    end;

    end;

    This Returns a Filename -  “Statement for "Customer No." "Customer Name" as of "Start Date" .”

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 3,401

#2
Sumit Singh Profile Picture

Sumit Singh 2,692

#3
YUN ZHU Profile Picture

YUN ZHU 1,935 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans