This article outlines step by step how to generate a document and save it to a Dynamics 365 record as a note attachment and to SharePoint via Power Automate.
In the following example, we will create an automated cloud flow that generates a welcome letter and attaches it to a contact after a contact has been created.
Prerequisites: To use the DocumentsCorePack Connector, you will need to get an API key from the service configuration. Learn more about how this works here.
Step 1: Creating the flow
Begin by creating a new flow and selecting a trigger. In our case, we will build an automated cloud flow. We will select When a row is added, modified, or deleted as the trigger.
Step 2: Setting our starting parameters
Fill in the parameters accordingly. We will set Change Type to Added and set the Table Name to Contacts.
Step 3: Adding our action
Next, we will add a new action to our flow. Search for the DocumentsCorePack Connector and select Create document (sync) (V3) from the list of actions.
Step 4: Configuring our action
After selecting the action, the following window will pop up. Please fill out the following fields:
❶ Body/Template: Choose a template
❷ Row ID: Select the unique identifier of the record to run this template for
❸ FileType: Select a file type
❹ Save To SharePoint: Choose whether or not to save the generated document to SharePoint. The document will be stored in the document location of the record the document is created for.
❺ Attach to [Row ID]: The unique identifier of the record to attach this document to.
❻ Attach to [Table]: The table the generated document should be attached to
❼ Body/Environment: The environment this action should be used in
Please note: Make sure that the base entity of your template matches the entity of your selected trigger.
Our action will be filled out as shown below:
Optional Step: An alternative approach
Instead of using the Create document step to attach the generated document to the record, it is also possible to add an extra step to the flow and attach it there.
Add the Attach DocumentJob as note (V3) action after the Create document action. The following parameters can be configured:
❶ DocumentJob ID: The DocumentJob ID of the generated document
❷ Table name: Choose a table to attach the note to
❸ Row ID: ID of the record to attach the note to
Please note: You can also add a note description or a note subject to help organize your notes.
This action would be filled as follows:
Once your flow has been set up, save it.
Step 5: Testing the Flow
You can directly start your flow within Dynamics 365 by pressing the Test button.
After your flow runs successfully, the created document is attached to the new contact as a PDF.
If you have configured the Create document action to save the document to SharePoint, then the document will be found under the Documents tab of the record.
Back to “The DocumentsCorePack connector for PowerApps and PowerAutomate (Microsoft Flow)“.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.