• Release History
  • Documentation
  • Back to www.mscrm-addons.com
  • Release History
  • Documentation
  • Back to www.mscrm-addons.com
home/Knowledge Base/DocumentsCorePack(DCP)/Step-by-Step: Generate documents in Power Automate (Microsoft Flow) using the Dataverse connector

Step-by-Step: Generate documents in Power Automate (Microsoft Flow) using the Dataverse connector

1930 views 0 Updated on January 23, 2023

In this article, we will showcase an alternative method for DCP to generate and process documents within Power Automate (Microsoft Flow).

Please Note:  We highly recommend using the new certified DocumentsCorePack (DCP) connector instead. Please go to this article to learn how to use this certified connector. Power Automate is becoming more powerful every day and will potentially replace the long-standing classic Dynamics 365 workflows.

Continue reading if you prefer to learn more about the alternative method.

 

How it works:

When using DCP, every document that has to be generated is defined by a record of an entity called AutoMergeWorkingItem. Here is the record of all mandatory definitions to generate the document:

  1. Record to use: Defines what record the document should be generated for (account, quote, etc.).
  2. Template to execute: Defines the DCP template that should be used to generate the document.
  3. Output format: The filetype that the document should be generated and returned as (pdf, docx, html, etc.).
  4. (Optional) Processing settings: DCP allows you to not only generate a document, but to also process the document by definitions on the AutoMerkeWorkingItem record (e.g. Print, Save to SharePoint, Send for e-Signing, etc.).

Once such an AutoMergeWorkingItem is created, the DCP service will generate the document and deliver it back as an attachment to this record. Essentially, in order to generate a document within Flow, you must Create an AutoMergeWorking Item Record.

Note: The mandatory parameters required can be brought into the flow in various ways. For example, you could build a Canvas App that passes the parameters to the Flow, or you can simply use the Dataverse connector or Dynamics 365 connectors within Flow to load them (see figure below).



Document generation request schema of DocumentsCorePack.
Figure 1: Document generation request schema of DocumentsCorePack
 

 

Step-by-Step: Create an AutoMergeWorkingItem in Power Automate (Microsoft Flow)

Now that we know what is needed: Let’s take a look at what such a document generation request must look like. Our use case is to generate a quote document in PDF format upon activation of the quote.

Note: In our scenario, we are using the Dataverse connector.

 

Step 1

The Trigger of the flow: In our scenario, the flow is designed to be triggered by a change of the status field of the quote entity. Start with the When a row is added, modified or deleted step and then fill out the information as follows:

The flow trigger (when a row is added, modified, or deleted).

Figure 2: The Trigger of the flow

What’s important: We will need the context of this step as it defines the record our document needs to pull the data from. So, we have the first required parameter: The record to use.

Step 2

Get Template to execute: Here we use the Dataverse “Get a row by ID” action to load our template. Since we always want to use the same quote-template, we make it simple and “hardcode” our template.

Get template to execute with the "Get a row by ID" action.

Figure 3: Get template to execute

So where does this GUID in the item identifier come from? To answer this, you must know that every template designed with the DCP Template Designer is stored as a record of the mscrm-addons.com DocumentsCorePack Template entity. As shown in the image below, this is the entity we are getting a record of.

You can open the template record you want to use and copy the GUID from the URL, as highlighted below.

Open the template record and copy the GUID.

Figure 4: Open template record

To summarize: This Get a row by ID step will provide us with the second parameter: The template to use. As we know that our output format should be PDF, we are all set to finally define our document generation request.

Step 3

Create AutoMergeWorking Item: As all parameters are now clear, we can use the Dataverse “Add a new row” action to create our document generation request as follows.

Create an AutoMergeWorkingItem with the "Add a new row” action.

Figure 5: Create AutoMergeWorking Item

We create a record of the entity MSCRM-ADDONS.COM AutoMergeWorkingItem and choose the action to be Create Document. We can also give it a name to later identify and review the documents generated via this Flow. Now we need to set our parameters.

a. Record to pull data from (PrimaryRecordUrl).

Create the record of the MSCRM-ADDONS.COM AutoMergeWorkingItem entity.

Figure 6: Record to pull data from (PrimaryRecordUrl)

This can be a challenging point. We copied the URL of a quote we opened in Dynamics and replaced it with the Quote parameter (Unique identifier of the quote from our Flow-Trigger action).

b. Template to Execute (TemplateToExecute).

Use the unique identifier to determine the template to execute.

Figure 7: Template to Execute (TemplateToExecute)

Here we reference the Unique Identifier parameter of our Get a row by ID step, where we loaded the template above.

c. FileType (SaveAs Value): This is a simple one – we simply select “PDF” from our picklist.

Select the file type.

Figure 8: FileType (SaveAs Value)

And that’s it! So every time a quote gets activated, we will now have a document generated.

Next Steps

Naturally you want to do something with the document once it is generated. As outlined above, you can either use the AutoMergeWorkingItem to process the document, or you can process the document within your flow. The generated document can be found on the AutoMergeWorkingItem record -> Created Document section.

Note: This field will be filled when DCP has successfully created the document. You will have to wait for the AutoMergeWorkingItem record to become inactive. This tells you that the document is ready.

AutoMergeWorkingItem information: Inactive status

Figure 9: AutoMergeWorkingItem information: Inactive status

That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.

Was this helpful?

Yes  No
Related Articles
  • AssureSign for DocumentsCorePack
  • How to conditionally remove a watermark in DocumentsCorePack templates
  • Document Processing with DocumentsCorePack (DCP)
  • How to activate SharePoint in DocumentsCorePack
  • Fillable PDF forms
  • Document concatenation in DocumentsCorePack 
Latest Articles
  • Office Theme Support of DocumentsCorePack
  • AssureSign for DocumentsCorePack
  • Dynamic Document Properties
  • How to conditionally remove a watermark in DocumentsCorePack templates
  • Document Processing with DocumentsCorePack (DCP)
Popular Articles
  • Where do I find the Unique Organization name in Microsoft Dynamics 365?
  • DocumentsCorePack Online Service Configuration
  • mscrm-addons.com Application Access for Dynamics 365 (App Access) – DocumentsCorePack
  • DocumentsCorePack Template Designer – Getting Started
  • Step-by-Step: How to configure a One-Click-Action
Top Rated Articles
  • IMPORTANT information for Dynamics 365 online customers using DocumentsCorePack and/or AttachmentExtractor
  • How to activate the DocumentsCorePack connector for PowerApps & Microsoft Flow
  • Step-by-Step: How to configure a One-Click-Action
  • Online Services: Required Application Permissions
  • How licenses are counted
Categories
  • *News and General Infos* 51
  • Webinars 34
  • Template Designer(DCP 173
  • DocumentsCorePack(DCP 191
  • TelephoneIntegration (TI 65
  • AttachmentExtractor (AE 62
  • PowerSearch (PS 48
  • ActivityTools (AT 59
  • SmartBar (SB 53
  • GroupCalendar (GC 46
Our Vision

“We see it as our purpose to provide products that simplify and speed up our customers’ Microsoft Dynamics 365 experience.”

Knowledgebase
LogIn
mscrm-addons.com
  • Products
  • Online Shop
  • Downloads
  • My Account
About Us
  • About Us
  • Case Studies
  • Newsletter
  • Partner Program
  • Contact
Support
  • Support
  • Terms & Conditions
  • Documentation
  • Webinars
  • Legal Documents
  • Impressum
  • © 2022 www.mscrm-addons.com. All Rights Reserved.