This article outlines how to generate a document and send it with Microsoft Flow.
In this step-by-step description, we create an on-demand Flow that executes a DCP template and sends the result as an email in Dynamics 365.
Start by creating a new Flow and selecting a trigger.
We build an instant cloud flow and select “When a row is selected” as our trigger.
Now select the “Environment” and the “Table Name”. Please select the entity(table) from which you want to start. In this example, we start from the entity(table) “Account”.
Click on [New step] and search for the “Add a new row” action of the Microsoft Dataverse connector.
Select “Email Messages” as “Table name” and click on [new step].
Search for the DocumentsCorePack Connector and select “Create Document Job (sync)” within the list of actions.
Right after you have selected “Create Document Job (sync)”, the following screen will pop up.
Please fill out the following fields.
❶ TemplateId: Select the DCP template that you want to use in this document job.
❷ EntityId: Select a Dynamics 365 source record id.
❸ FileType: Select HTML as Filetype.
Please note: Make sure that the base entity of your template matches with the entity of your selected Trigger!
Add the next step and go on with the procedure, to look for the DocumentsCorePack Connector. Then select the “Attach DocumentJob to Email” action. In order to use the result as email provide the following configuration.
❶ DocumentJobId: Please provide the ID of the previously created DocumentJob.
❷ Email Id: Enter the email where the document should be attached.
The last step will be the “Send email” action of the DocumentsCorepack connector.
Provide the Email record, a sender, and a recipient before you save your flow.
Execute your Flow
It makes no difference from where you start your Flow. We do it directly within Dynamics 365 by pressing the [Run flow]-button.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to firstname.lastname@example.org.