Do you need to export an invoice as PDF from Business Central to OneDrive with Power Automate? Do you want to take your workflows to the next level?
I'll tell you how to do it step by step. Let's get started.
The integration between Power Automate and Dynamics 365 Business Central allows you to run flows in the context of a selected record.
Steps to export a PDF invoice in Business Central
How does it work? Thanks to the "For a selected record" trigger from the Business Central connector, your flows can automatically appear on the specific Business Central page or, if you specify a table, on all pages that use that table as a source.
We start in Power Automate by creating an "Instant cloud flow"
We give a name to the flow.
For this example, we use the "For a selected record (V3)" trigger
We select page 143 (Posted Sales Invoices page) as the only source where the workflow should be visible in the user interface (UI). The workflow trigger is defined as follows:
Observing the trigger, we can see that the Environment Name and Company Name parameters are optional.
This means that if we leave them blank, the workflow will be available for any environment and any company, respectively. In our example, we have completed both.
Once the trigger is defined, it's time to configure the actions to execute. For the selected posted sales invoice record, we need to perform the following tasks:
- Retrieve the record reference
- Get the associated PDF document content
- Save the PDF to OneDrive
-
Retrieve the record reference
To retrieve a specific record from Dynamics 365 Business Central, you can use the "Get record" action as follows:
At this point, we select "salesInvoices" as the table (API) name and then pass the "System Id" field (returned by the workflow trigger) as the "Row Id" parameter to retrieve the record.
2. Get the associated PDF document content
Once we have the record, to get the PDF content of the selected document, you can use the "Get image, file, or document" action as follows:
This action needs the path of the “pdfDocumentContent” element for the selected record and the record ID (here, I'm passing the ID of the Get record action).
3. Save the PDF to OneDrive
Once you have the PDF content, you can store it in OneDrive using the “Create file” action from the OneDrive connector like this:
Once saved, the workflow will appear on the specified page in Dynamics 365 Business Central (under the “Automate” action group):
We run it and check that it works correctly:
The invoice in PDF format, in my OneDrive:
Why use Power Automate to integrate tasks in Business Central?
Power Automate is a powerful tool that allows you to automate workflows and tasks in Dynamics 365 Business Central.
By leveraging its capabilities, users can create automated processes, improve efficiency, and reduce manual workload in their organization.
From data integration to notifying important events, Power Automate offers a versatile solution to optimize business management.
Read also: Power Automate to join applications. Practical integration case
I hope this has been very helpful.
Dynamics 365 Development
ABD Consulting and IT Solutions