• Archive
  • Back to www.mscrm-addons.com
  • Archive
  • Back to www.mscrm-addons.com
home/Knowledge Base/DocumentsCorePack(DCP)

Step-by-Step: How to generate documents in Power Automate (Microsoft Flow)

305 views 0

Written by Administrator
November 6, 2019

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
  • TemplateImportExport Console Application – DCPIE.exe
  • How to trigger a Microsoft Flow from dialog
  • Only count users with security role for licensing
  • Generate app password when using Office 365 connection type
  • How do I create a document and attach it or use it as the body of an email in a single workflow step in MS Dynamics 365 Online?
  • How to check the existence or the value of a SettingsKey in MS Dynamics 365
Latest Articles
  • TemplateImportExport Console Application – DCPIE.exe
  • How to trigger a Microsoft Flow from dialog
  • General Settings – DocumentsCorePack Server Based
  • How to use the Insert-as-Picture-Link-Field-button in Dynamics-365
  • What is “documents incl. per month”
Popular Articles
  • How to activate the DocumentsCorePack connector for PowerApps & Microsoft Flow
  • How licenses are counted
  • Where do I find the Unique Organization name in Microsoft Dynamics 365?
  • How to work with the new DocumentsCorePack custom connector for PowerAutomate (Microsoft Flow)
  • DocumentsCorePack Charts Feature (Dynamics 365)
Top Rated Articles
  • How to activate the DocumentsCorePack connector for PowerApps & Microsoft Flow
  • Can you save data capacity by moving email content?
  • How to work with the new DocumentsCorePack custom connector for PowerAutomate (Microsoft Flow)
  • DocumentsCorePack Online Scheme
  • Recap of the first virtual eXtreme365 & Community Summit event
Categories
  • *News and General Infos* 43
  • Template Designer(DCP 151
  • DocumentsCorePack(DCP 146
  • TelephoneIntegration (TI 62
  • AttachmentExtractor (AE 47
  • PowerSearch (PS 43
  • ActivityTools (AT 55
  • SmartBar (SB 50
  • GroupCalendar (GC 43
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
  • © 2020 www.mscrm-addons.com. All Rights Reserved.