Hi all,
I have a concern that when I download report from BC, the report always named after the report name.
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!
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" .”
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156