This article outlines step-by-step how to automatically generate and send a quote document after activation of the quote inside Dynamics 365 via Power Automate using the DocumentsCorePack Connector.
In this example, our goal is to automatically generate and send a quote with an email description to a customer once a quote is activated. We will do this by creating a new automated Flow that executes a DocumentsCorePack Quote template and then sends the resulting quote document as an email attachment in Dynamics 365. Additionally, we will generate another template and add it to the email’s body.
Step 1
Start by creating a new automated Flow and selecting a trigger. In this example, we are building an automated cloud Flow and selecting When a row is added, modified, or deleted as the trigger.
Figure 1: Create an automated flow and select the trigger
Step 2
Next, select Modified for the Change Type. For the Table Name, select the base entity (table) that the Flow should be created for, which is the Quotes entity. Then select Organization for the Scope and open the advanced options.
Figure 2: Specify the trigger action
Step 3
When the statecode equals 1 for a quote, this means that the quote is activated. To make sure that this flow only runs for quotes that have been activated, type statecode in the Select Columns row and then type statecode eq 1 in the Filter Rows row, as shown in Figure 2.
Step 4
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: Create a new email message
Step 5
Add a new step and then search for the DocumentsCorePack connector and select Create document (sync) (V3) from the list of available actions.
Figure 4: Open the DCP Connector and select the Create Document (sync) (V3) action
Step 6
After selecting the action, the corresponding window will appear as shown below. The fields should be filled out as follows:
- Template: Select the DocumentsCorePack template to be used in the document generation process. In this example, we are using our Quote Template for the template. (Click here to learn how to create a DocumentsCorePack template.)
- Row ID: Add Quote 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.
Figure 5: Complete the create document step
Step 7
To add our email content, we can add another step and select Create document (sync) (V3) under the DocumentsCorePack connector 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: Add the email content with another create document step
Step 8
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: Complete the last step: Send email
Test Your Flow
After saving your flow, select the Test button. Then navigate to your Dynamics 365 environment and access an inactive Quote record. Then activate the flow and navigate back to Power Automate to view the status of your flow as it progresses after the initial activation trigger.
Figure 8: Test your flow
Here is a sample result:
Figure 9: Sample result
Now you know how to how to generate and send a quote document after activation via Power Automate.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.