Currently, when exporting a report, the filename is assumed from the report name. It is time-consuming to manually rename each exported file. If it were possible to build the filename through code, it would save time when exporting a large set of reports to send to customers or vendors.
Example of currently exporting three custom sales invoices:
Sales Invoice.pdf
Sales Invoice(1).pdf
Sales Invoice(2).pdf
These would be more helpful:
S-INV 101010 - Customer A.pdf
S-INV 101011 - Customer B.pdf
S-INV 101012 - Customer C.pdf
Comments
The OnGetFilename event runs very well. Remember to set `Success` to `true` and escape any special characters using the `RegEx` codeunit. Below is a sample code demonstrating its use:[EventSubscriber(ObjectType::Codeunit, Codeunit::ReportManagement, OnGetFilename, '', false, false)]local procedure OnGetFilename(ReportID: Integer; Caption: Text[250]; ObjectPayload: JsonObject; FileExtension: Text[30]; ReportRecordRef: RecordRef; var Filename: Text; var Success: Boolean)var RegEx: Codeunit Regex;begin Filename := 'My Custom Name Goes Here'; Filename := RegEx.Replace(Filename, '[^A-Za-z0-9_]', ''); Success := true;end;
Category: Development
I tried using the 'OnGetFilename' event from the ReportManagement Codeunit, but unfortunately, it didn't work (v24.4.2). I believe this is a basic functionality that should be implemented as soon as possible, as it would prevent our customers from having to manually rename files, saving them a lot of time.
Category: Development
Definitely needed. It's a very basic feature and the lack of this creates additional work when sending out reports to customers or vendors.
Category: Development
It's ridiculous that we are unable to do such a basic feature. The event is not firing and I'm unable to complete a task for our customer and won't be able to do it until you fix it! This is not a feature, this is bug. Fixing it is not like you'd have to invent a new ERP system...
Category: Development
Unfortunately, the 'OnGenerateFileNameOnAfterAssignFileName' event is not triggering for custom reports. The ability to modify PDF names is still unavailable, and this feature remains necessary. Kindly address this concern.
Category: Development
check event OnGenerateFileNameOnAfterAssignFileName on Codeunit::"Custom Layout Reporting"seems does exactly that.ps: not tested
Category: Development
Still major must have feature. Every filename has to be changed manually - that' very time consuming and interrupts the workflow.
Category: Development
everybody needs this,this is such a pain in the ass
Category: Development
Really import feature we had for NAV, but not for BC Cloud
Category: Development
Would save a lot of time if the printed report (to PDF or Word) would have filename with document ID instead of the template name.
for example a Sales invoice (V-ORD20-12345_YYYYDDMM_HHMM)
Category: Development
Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future.
Best regards,
Business Central Team