• Documentation
  • Back to www.mscrm-addons.com
  • 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

1214 views 0 Updated on June 24, 2021

IMPORTANT: The way which is described here is already outdated and only useful if you want to manually generate AutoMergeworking Items.
We highly recommend to use the new certified DocumentsCorePack connector. Please go to following article to learn how you can use the certified connector.

Power Automate is becoming more powerful every day and potentially is about to replace the long-standing classic Dynamics 365 workflows. In this blog, we will present and showcase how DocumentsCorePack allows us to generate and process documents within Power Automate (Microsoft Flow).

How it works:
When using DocumentsCorePack every document that has to be generated is defined by a record of an entity called “AutoMergeWorkingItem”. This record holds all mandatory definitions to generate the document:

1. Record to use:  What record should the document be generated for (e.g. account, quote, etc.)
2. Template to execute: ​ Defines the DocumentsCorePack template that should be used to generate the document.
3. Output format: ​The Filetype the document should be generated and returned as Pdf, docx, Html.
4. (Optional) Processing settings: This is not a necessity but DocumentsCorePack allows to not just generate a document but 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 DocumentsCorePack service will generate the document and deliver it back as an attachment to this record. It becomes clear that in order to generate a document within Flow the only thing that needs to be done is to “Create an AutoMergeWorking Item Record”.

Note: The mandatory parameters required can be brought into flow in various ways. E.g. you could build a Canvas App that passes the parameters to the Flow or you can simply use the Common Data Service 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 how such a document generation request has to 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 common data service connector. Especially with the October 2019 update for the “Common Data Service (current environment)” it became a lot easier to do certain things like creating records. I want to emphasize though that it’s of course also possible to use the Dynamics 365 connector.

1. The Trigger of the flow: In our scenario, the flow is defined to trigger a change of the status field of the quote entity as follows:


The Trigger of the flow
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!

2. Get Template to execute: Here we use the Common Data Service- ‘Get Record’ 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
Figure 3: Get template to execute

​

So what do we have here? Where does this GUID in the item identifier come from? To answer this we have to know that every template designed with the DocumentsCorePack Template Designer is stored as a record of the “mscrm-addons.com DocumentsCorePack Template” entity. As can be seen on the screenshot this is the entity we are getting a record of.

You can e.g. open the template record you want to use and copy the GUID from the URL as you can see below.


Open template record
Figure 4: Open template record

To summarize: This ‘Get Record’ step will provide us with the second parameter: The template to use! As we also know that our output format should be PDF we are all set to finally define our document generation request!

3. Create AutoMergeWorking Item: As all parameters are now clear we can use the Common Data Service – Create Record action to create our document generation request as follows:


Create AutoMergeWorking Item
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 that is quite handy to maybe later identify and review the documents generated via this Flow. Now we need to set our parameters:

a. Record to pull data from (PrimaryRecordUrl):


Record to pull data from (PrimaryRecordUrl)
Figure 6: Record to pull data from (PrimaryRecordUrl)

This is kind of challenging at this point. We did copy 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):


Template to Execute (TemplateToExecute)
Figure 7: Template to Execute (TemplateToExecute)

Here we reference the Unique Identifier parameter of our “Get Record” step where we did load the template above.

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


FileType (SaveAs Value)
Figure 8: FileType (SaveAs Value)

And that’s it! We did it. So every time a quote gets activated we will now get a document generated.

Next steps: Naturally you want to do something with the document once generated. As outlined above you can either use the AutoMergeWorkingItem to process the document but you can also 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 DocumentsCorePack 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. 

reworkneeded.. reference to dcp connector is missing..

Was this helpful?

Yes  No
Related Articles
  • Control access to DocumentsCorePack One-Click-Actions via Dynamics 365 security roles
  • How to access mscrm-addons product settings in Dynamics 365
  • One-Click-Actions (OCAs) in DocumentsCorePack
  • Service Configuration options
  • Multipart documents in DocumentsCorePack
  • Azure Active Directory Licensing counts explained
Latest Articles
  • Control access to DocumentsCorePack One-Click-Actions via Dynamics 365 security roles
  • How to display various activity-attributes within multiple rows in Gantt view
  • Recap: European Power Platform Conference 2022
  • How to solve the issue with DocumentsCorePack fields in Arabic text
  • How to access mscrm-addons product settings in Dynamics 365
Popular Articles
  • DocumentsCorePack Online Service Configuration
  • Where do I find the Unique Organization name in Microsoft Dynamics 365?
  • mscrm-addons.com Application Access for Dynamics 365 (App Access) – DocumentsCorePack
  • How to activate the DocumentsCorePack connector for PowerApps & Microsoft Flow
  • How licenses are counted
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
  • Can you save data capacity by moving email content?
  • Online Services: Required Application Permissions
Categories
  • *News and General Infos* 50
  • Template Designer(DCP 160
  • DocumentsCorePack(DCP 181
  • TelephoneIntegration (TI 64
  • AttachmentExtractor (AE 55
  • PowerSearch (PS 43
  • ActivityTools (AT 57
  • SmartBar (SB 51
  • GroupCalendar (GC 45
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.