This article outlines, how to generate a document and save it to a Dynamics 365 record with Microsoft Flow.
In this step-by-step description, we create an on-demand Flow that executes a DCP template and saves the result to our starting record (Account) 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 DocumentsCorePack Connector. Within the list of actions select “Create Document Job (sync)”.
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 a 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 as note” action. In order to save the result as a note to the starting record provide the following configuration.
❶ DocumentJobId: Select the previously created DocumentJobId.
❷ Entity Id: Enter the ID field of the record, where the document should be attached to.
❸ Schemaname: Select the matching entity to your record.
You can add a Note description or a Note subject for organizing your notes. Now press the [Save]-button.
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.
After your Flow ran successfully, you can see the created document in the timeline.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to firstname.lastname@example.org.