Report File Name
Use the Report File Name trigger when you want a flow to decide the file name Business Central gives to a generated report – for example, to name a downloaded invoice after the customer and document number, add the date to an export, or follow a company-wide naming convention. The flow runs synchronously while Business Central is building the name and can either keep the name Business Central proposed or replace it.
One flow handles all the reports you care about: you configure a list of reports (one line each), and the flow fires whenever any of them produces a file. Unlike the PDF Print trigger, this trigger fires for any file type the report produces – PDF, Word, Excel, and others. The file extension is exposed as an output so the flow can decide for itself whether to act (for instance, only rename PDFs).
Typical examples include:
- Naming a downloaded sales invoice
Invoice <No.> - <Customer>.pdfinstead of the generic report caption. - Prefixing every exported report file with the posting date for easy sorting.
- Enforcing a naming convention across all documents a customer receives – invoices, credit memos, reminders – from a single flow.
What happens when the flow runs
- A user downloads, saves or exports a report from Business Central, and the platform builds a file name for the output.
- AutoFlow checks whether the report appears in the flow's configured report lines; if so, it starts the flow, handing it the name Business Central proposed plus details of the report and the underlying record.
- The flow runs to a Set report file name step. If it reaches one, the text from that step becomes the file name. If it finishes without one – or errors, or exceeds the configured Timeout – Business Central keeps the name it generated.
- Each invocation is logged as a standard AutoFlow execution.
Trigger configuration
- Reports – one line per report this flow reacts to. Reports not in the list never start the flow.
- Report – type the report number (e.g.
1306) and it is completed to "number - name", or pick the report with the assist-edit (…). - Source Table (optional per line) – the table the report runs on (e.g.
112for Sales Invoice Header). Type the table number or pick it with the assist-edit. With a table set, the trigger provides that report's source record as aRec_<report no.>output (see below) so its fields can be used in the file name. Leave it empty if the report has no single source record – the line still fires the flow, just without a record output.
- Report – type the report number (e.g.
- Timeout (sec) – how long the flow may run before Business Central keeps the original name. Applies to the whole trigger, not per line. Default 30 s. This is the user-perceived wait time while the file is prepared, so keep it as short as the flow allows.
Only one published flow can use this trigger. Publishing a second one fails fast – add more report lines to the existing flow instead.
Trigger outputs
The flow body has these outputs to work with:
| Output | Description |
|---|---|
ProposedFileName | The file name Business Central just generated, including the extension. A good starting point if you only want to tweak the name. |
ReportId | The object id of the report that produced the file (e.g. 1306). Branch on this to handle each configured report differently. |
Extension | The file extension Business Central assigned, e.g. .pdf, .docx, .xlsx. Branch on this if your flow should only rename certain file types. |
RecordCount | How many records the report output covers: 1 for a single document (the record fields are meaningful), greater than 1 for a combined/batch run, 0 when the report has no source record. Branch on this to fall back to the default name for multi-document runs. |
Rec_<report no.> | One per configured report line with a Source Table – e.g. Rec_1306 for report 1306. The source record of that report, as a reference: use {{<trigger-slug>.Rec_1306.FieldName}} to read its fields (customer name, document no., …). At runtime only the output of the report that actually fired carries a value, and only when RecordCount = 1. Lines without a Source Table have no record output. |
The Rec_<report no.> output names follow the configured report numbers. If you remove a line (or its Source Table), SmartField references like {{…Rec_1306.No.}} in the flow body stop resolving – update them together with the configuration.
Example flow
Naming downloaded Standard Sales Invoices after their number while also covering credit memos, but keeping the default name when several documents were printed at once:
- When a report file name is generated – Reports: line 1
1306(Standard Sales - Invoice) with Source Table112; line 21307(Standard Sales - Credit Memo) with Source Table114. - Decision –
{{<trigger-slug>.RecordCount}}equals1?- No → end the flow (no Set step) so Business Central keeps its default name.
- Case on
{{<trigger-slug>.ReportId}}:1306→ Set report file name – File Name =Invoice {{<trigger-slug>.Rec_1306.No.}} - {{<trigger-slug>.Rec_1306.Sell-to Customer Name}}.pdf.1307→ Set report file name – File Name =Credit Memo {{<trigger-slug>.Rec_1307.No.}}.pdf.
When a user downloads a single invoice, it arrives named after the customer and document number. A combined run of many invoices keeps the default name. If the flow is slow, hits an error, or doesn't finish within Timeout, the file keeps the name Business Central generated – the user never sees a failure.
The name you set replaces the whole file name, including the extension. Be sure to include the extension you want – the original is available as the Extension output if you want to reuse it.
When the flow doesn't fire
- The report that produced the file is not on the flow's report lines.
- The flow body itself generates a report (the trigger does not re-enter while a flow is already running, to avoid loops).
When a report produces several documents in one run, Business Central builds a file name for each one, so the flow can fire more than once per run. Keep the flow lightweight.