This article outlines step-by-step how to generate and send a document using the DocumentsCorePack (DCP) connector for Microsoft Flow.
In this example, our goal is to generate and send an email to a customer. We want to attach a document to the email that contains an overview of their related quotes. We will do that by creating an on-demand Flow that executes a DocumentsCorePack template and sends the resulting document as an email attachment in Dynamics 365. Additionally, we will generate another template and add it as the email’s body.
Steps
1. Start by creating a new Flow and selecting a trigger. In this example, we are building an instant cloud Flow and selecting When a row is selected as the trigger.
Figure 1: Create a new flow and select a trigger.
2. Select the Environment and Table Name. For the Table Name, select the base entity (table) that the Flow should be created for. For this example, we are creating it for the Account entity.
Figure 2: Selecting an environment and base entity (table)
3. Click on + New step and search for the Add a new row action from the Microsoft Dataverse connector. We want to send an email, so we select Email Messages for the Table name and click on + New step again.
Figure 3: Creating a new email message
4. Search for the DocumentsCorePack connector and select Create document (sync) (V3) from the list of available actions.
Figure 4: Finding the correct DCP action
5. After selecting the action, the corresponding window will appear as shown below. The fields should be filled out as follows:
- Template: Select the DCP template to be used in the document generation process. In this example, we are using our AccountQuoteOverview template.
- Row ID: Add Account from the Dynamic content window.
- File Type: Select PDF as the file type. This will attach the generated document as a PDF to our email.
- Attach to Email: Add Email Message from the Dynamic content window.
Please note: Make sure that the base entity from the selected template matches with the entity of your selected trigger.
Figure 5: Adding our attachment as a PDF.
6. To add our email content, we can add another step and select Create document (sync) (V3) from the list again. This step is similar to the previous step. However, we will be using a different template for our email content, and the file type must be set to HTML.
Figure 6: Adding the email content.
7. Finally, select + Next Step and select Send email (V3) under the DocumentsCorePack connector. Here, provide the email record, a sender, and a recipient before saving your Flow.
Figure 7: Providing the email information.
Executing your Flow
We created our Flow for the Account entity, so we can run this Flow from any Account record. To start it, go to an Account record and click the Flow button.
Figure 8: Activating the Flow.
From there, select the created Flow, and then select the Run Flow button.
Figure 9: Running the Flow.
A sample result:
Figure 10: The final result.
Try it out yourself!
Try yourself to generate and send a document using DocumentsCorePack for Microsoft Flow. To try the Flow described in this example, please download the .zip below in the “Attached File” section and follow the steps shown in this article to import it.
IMPORTANT: The Template and User fields in the Flow must be set to a value from within your own environment. Additionally, please note that you will need to create the following connections in Power Automate to import this Flow:
- Microsoft Dataverse (legacy)
- Microsoft Dataverse
- DocumentsCorePack
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.