Skip to main content

Notifications

Announcements

No record found.

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!

  • Suggested answer
    Hein Kruger Profile Picture
    511 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" .”

  • Suggested answer
    JAngle Profile Picture
    89 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

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 Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

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

#1
YUN ZHU Profile Picture

YUN ZHU 365 Super User 2025 Season 1

#2
Mansi Soni Profile Picture

Mansi Soni 242

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 226 Most Valuable Professional

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans