News.mscrm-addons.com BlogHello and welcome to our blog! What can we do for you? Are you looking for further technical information or step-by-step instructions to our products? Or would you like to read the latest news on mscrm-addons? Please feel free to browse our blog for detailed information and to share our posts! https://www.mscrm-addons.com/BlogStep-by-Step: How to generate documents in Power Automate (Microsoft Flow)https://www.mscrm-addons.com/Blog/PostId/10236/step-by-step-how-to-generate-documents-in-microsoft-flow*General*,DocumentsCorePack (DCP),DCP 365Wed, 06 Nov 2019 13:13:08 GMT<p style="text-align: justify;">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).</p> <p style="text-align: justify;"><strong><span style="font-size: 18px; color: #0077b3;">How it works:</span></strong><br /> When using DocumentsCorePack every document that has to be generated is defined by a record of an entity called &ldquo;AutoMergeWorkingItem&rdquo;. This record holds all mandatory definitions to generate the document:&nbsp;</p> <p style="text-align: justify;"><strong>1. Record to use:&nbsp;</strong>&nbsp;What record should the document be generated for (e.g. account, quote, etc.)<br /> <strong>2. Template to execute:</strong> ​&nbsp;Defines the DocumentsCorePack template that should be used to generate the document.<br /> <strong>3. Output format: </strong>​The Filetype the document should be generated and returned as Pdf, docx, Html.&nbsp;<br /> <strong>4. (Optional) Processing settings:</strong> 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.).&nbsp;</p> <p style="text-align: justify;">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 <strong>&ldquo;Create an AutoMergeWorking Item Record&rdquo;</strong>. </p> <p style="text-align: justify;"><strong>Note: </strong>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).</p> <div class=" data-plugin-options="> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"> <a title="Document generation request schema of DocumentsCorePack " href="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure1.png"> <img alt="Document generation request schema of DocumentsCorePack" width="544" height="265" class="img-responsive" src="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure1.png" /> </a></div> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>Figure 1: Document generation request&nbsp;schema of DocumentsCorePack</em></div> </div> <p>&nbsp;</p> <p><strong><span style="font-size: 18px; color: #0077b3;">Step-by-Step: Create an AutoMergeWorkingItem in Power Automate (Microsoft Flow)<br /> </span></strong>Now that we know what is needed: Let&rsquo;s take a look at how such a document generation request has to look like. </p> <p>Our use case is to generate a quote document in PDF &ndash; format upon activation of the quote. </p> <p><strong>Note: </strong>In our scenario, we are using the common data service connector. Especially with the October 2019 update for the &ldquo;Common Data Service (current environment)&rdquo; 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.<strong><span style="font-size: 18px; color: #0077b3;"><br /> </span></strong></p> <p><strong>1. The Trigger of the flow:</strong> In our scenario, the flow is defined to trigger a change of the status field of the quote entity as follows:</p> <div class=" data-plugin-options="> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"> <a title="The Trigger of the flow" href="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure2.png"> <img alt="The Trigger of the flow" width="316" height="154,5" class="img-responsive" src="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure2.png" /> </a></div> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>Figure 2: The Trigger of the flow</em></div> </div> <p>&nbsp;</p> <p><strong>What&rsquo;s important:</strong> 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! </p> <p><strong>2. Get Template to execute:</strong> 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 &ldquo;hardcode&rdquo; our template.&nbsp;</p> <div class=" data-plugin-options="> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"> <a title="Get template to execute" href="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure3.png"> <img alt="Get template to execute" width="317" height="88,5" class="img-responsive" src="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure3.png" /> </a></div> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>Figure 3: Get template to execute</em></div> <p class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>​</em></p> </div> <p>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 &ldquo;mscrm-addons.com DocumentsCorePack Template&rdquo; entity. As can be seen on the screenshot this is the entity we are getting a record of.</p> <p>You can e.g. open the template record you want to use and copy the GUID from the URL as you can see below.&nbsp;</p> <div class=" data-plugin-options="> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"> <a title="Open template record" href="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure4.png"> <img alt="Open template record" width="650,5" height="208,5" class="img-responsive" src="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure4.png" /> </a></div> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>Figure 4: Open template record</em></div> </div> <p>&nbsp;</p> <p><strong>To summarize:</strong>&nbsp;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!&nbsp;</p> <p><strong>3. Create AutoMergeWorking Item: </strong>As all parameters are now clear we can use the Common Data Service &ndash; Create Record action to create our document generation request as follows:&nbsp;</p> <div class=" data-plugin-options="> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"> <a title="Create AutoMergeWorking Item" href="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure5.png"> <img alt="Create AutoMergeWorking Item" width="420" height="168" class="img-responsive" src="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure5.png" /> </a></div> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>Figure 5: Create AutoMergeWorking Item</em></div> </div> <p>&nbsp;</p> <p>We create a record of the Entity &ldquo;MSCRM-ADDONS.COM AutoMergeWorkingItem&rdquo; and choose the Action to be &ldquo;Create Document&rdquo;. 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: </p> <p>a. Record to pull data from (PrimaryRecordUrl):</p> <div class=" data-plugin-options="> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"> <a title="Record to pull data from (PrimaryRecordUrl)" href="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure6.png"> <img alt="Record to pull data from (PrimaryRecordUrl)" width="470,5" height="65,5" class="img-responsive" src="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure6.png" /> </a></div> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>Figure 6: Record to pull data from (PrimaryRecordUrl)</em></div> </div> <p>&nbsp;</p> <p>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 &ldquo;Quote&rdquo;-parameter (Unique identifier of the quote from our Flow-Trigger action).&nbsp;</p> <p>b. Template to Execute (TemplateToExecute):</p> <div class=" data-plugin-options="> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"> <a title="Template to Execute (TemplateToExecute)" href="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure7.png"> <img alt="Template to Execute (TemplateToExecute)" width="479" height="26" class="img-responsive" src="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure7.png" /> </a></div> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>Figure 7: Template to Execute (TemplateToExecute)</em></div> </div> <p>&nbsp;</p> <p>Here we reference the Unique Identifier parameter of our &ldquo;Get Record&rdquo; step where we did load the template above.&nbsp;</p> <p>c. FileType (SaveAs Value): This is a simple one &ndash; we simply select &ldquo;PDF&rdquo; from our picklist.&nbsp;</p> <div class=" data-plugin-options="> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"> <a title="FileType (SaveAs Value)" href="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure8.png"> <img alt="FileType (SaveAs Value)" width="512,5" height="27" class="img-responsive" src="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure8.png" /> </a></div> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>Figure 8: FileType (SaveAs Value)</em></div> </div> <p>&nbsp;</p> <p><strong>And that&rsquo;s it!</strong> We did it. So every time a quote gets activated we will now get a document generated.</p> <p><strong>Next steps: </strong>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 -&gt; Created Document section. </p> <p><strong>&nbsp;Note</strong>: This field will be filled when DocumentsCorePack successfully created the document. You will have to wait for the AutoMergeWorkingItem record to become &ldquo;inactive&rdquo;. This tells you that the document is ready.&nbsp;</p> <div class=" data-plugin-options="> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"> <a title="AutoMergeWorkingItem information: Inactive status" href="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure9.png"> <img alt="AutoMergeWorkingItem information: Inactive status" width="647,5" height="445" class="img-responsive" src="/Portals/0/Blog/StepByStep_How_to_generate_documents_in_Microsoft_Flow/Figure9.png" /> </a></div> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>Figure 9: AutoMergeWorkingItem information: Inactive status</em></div> </div> <p>&nbsp;</p> <p><span style="background-color: #fcfcfc; text-align: justify;">&nbsp;</span></p> <p><span style="font-size: 13px;"><span style="background-color: #fcfcfc; text-align: justify;"><strong>That's it!</strong></span><span style="background-color: #fcfcfc; text-align: justify;">&nbsp;We appreciate your feedback! Please share your thoughts by sending an email to&nbsp;</span><a href="mailto:support@mscrm-addons.com" style="background-color: #fcfcfc; text-align: justify;">support@mscrm-addons.com</a><span style="background-color: #fcfcfc; text-align: justify;">.&nbsp;</span></span></p>10236How to save generated documents to a specified SharePoint URLhttps://www.mscrm-addons.com/Blog/PostId/10138/how-to-save-generated-documents-to-a-specified-sharepoint-url*General*,DocumentsCorePack (DCP),PowerSearch (PS),PS 365Fri, 13 Jul 2018 09:32:18 GMT<p style="text-align: justify;">In this blog article, you will learn how the DocumentsCorePack ServerBased functionality can be used to save generated documents to a specified SharePoint URL in a workflow. More information about how to create a workflow can be found&nbsp;<a href="http://www.mscrm-addons.com/Blog/PostId/9982/how-do-i-create-a-document-and-attach-it-to-an-email-quick-and-easy-in-ms-dynamics-365">here</a>. We will skip this part and focus on the step which saves the generated documents to SharePoint.&nbsp;</p> <p style="text-align: justify;">Therefore, we have to create a new MSCRM-ADDONS.com AutoMergeWorkingItems, which makes sure that the generated document will be saved to a specified SharePoint URL. To do so, please add a new step to your workflow and set click on the&nbsp; <strong>[Set Properties]</strong>-button. The properties for this step could look like in the example below:&nbsp;</p> <div class=" data-plugin-options=" style="text-align: justify;"> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"> <a title="MSCRM-ADDONS.com AutoMergeWorkingItems properties " href="/Portals/0/Blog/How_to_save_generated_documents_to_a_specified_SharePointUrl/Figure1.png"> <img alt="MSCRM-ADDONS.com AutoMergeWorkingItems properties" class="img-responsive" src="/Portals/0/Blog/How_to_save_generated_documents_to_a_specified_SharePointUrl/Figure1.png" width="484,5" /> </a></div> <div class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}"><em>Figure 1: MSCRM-ADDONS.com AutoMergeWorkingItems properties</em></div> </div> <p style="text-align: justify;">&nbsp;</p> <p class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}" style="background-color: #fcfcfc; text-align: justify;"><span style="text-align: justify;"><span style="font-size: 24px; color: #0077b3;">❶</span>&nbsp;<span style="color: #0077b3;">Name</span><br /> </span><span style="text-align: justify;">Type in the name of your newly created step - a name that reminds you of what it contains.&nbsp; In this case "Save File to SharePoint" makes sense.&nbsp;</span></p> <p style="background-color: #fcfcfc; text-align: justify;"><span style="font-size: 24px; color: #0077b3;">❷&nbsp;</span><span style="text-align: justify;"><span style="color: #0077b3;">AutoMergeAction</span><br /> </span><span style="text-align: justify;">Open the drop-down menu and select CreateDocument<strong>.&nbsp;</strong></span>Select this option to create a document in any Microsoft Dynamics 365 standard and/or custom entity.</p> <p style="background-color: #fcfcfc; text-align: justify;"><span style="font-size: 24px; color: #0077b3;">❸&nbsp;</span><span style="text-align: justify; color: #0077b3;">PrimaryRecordUrl<br /> </span><span style="text-align: justify;">Insert the PrimaryRecordUrl here by using the Form Assistant on the right side (highlighted in yellow). A description of&nbsp;how to set a PrymaryRecordsUrl-field can be found in this&nbsp;<a href="http://www.mscrm-addons.com/Blog/PostId/9982/how-do-i-create-a-document-and-attach-it-to-an-email-quick-and-easy-in-ms-dynamics-365">blog article</a>.&nbsp;</span></p> <p class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}" style="background-color: #fcfcfc; text-align: justify;"><span style="text-align: justify;"><span style="color: #0077b3;"><span style="font-size: 24px;">❹</span>&nbsp;TemplateToExecute</span><br /> Open the Look up-record and select the template which should be executed.&nbsp;</span></p> <p class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}" style="background-color: #fcfcfc; text-align: justify;"><span style="text-align: justify;"><span style="font-size: 24px; color: #0077b3;">❺&nbsp;</span><span style="color: #0077b3;">SharePoint URL<br /> </span></span><span style="text-align: justify;">Insert here your SharePoint URL, which can be dynamic or static.&nbsp;<br /> If you want to specify a folder, the url has to end with a '/'. eg. https://xyz.sharepoint.com/sites/dcp/account/<br /> If you want to specify a folder and a file name then you type the full url with the filename, but&nbsp; without extension into this field. eg. https;//xyz.sharepoint.com/sites/dcp/account/myfilename</span></p> <p class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}" style="background-color: #fcfcfc; text-align: justify;"><span style="text-align: justify;">​</span></p> <p style="text-align: justify;"><span style="font-size: 24px; color: #0077b3;">❻&nbsp;</span><span style="text-align: justify; background-color: #fcfcfc; color: #0077b3;">Direction<br /> </span><span style="text-align: justify; background-color: #fcfcfc;">Select the direction of your SharePoint service here. In this case "Entity to SharePoint" because we want to save a generated document based on an entity to SharePoint.&nbsp;</span></p> <p class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}" style="text-align: justify;"><span style="text-align: justify;">After defining the properties please&nbsp;save your&nbsp;newly created process and do not forget to activate it in the <strong>My Processes</strong>-section by hitting the&nbsp;<strong>[Activate]</strong>-button in the command bar.&nbsp;&nbsp;</span></p> <p class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}" style="text-align: justify;"><span style="text-align: justify;">Please also have a look at this <a href="http://www.mscrm-addons.com/Blog/PostId/10080/how-to-upload-a-sharepoint-document-to-an-email-in-a-workflow">blog article</a> to learn how to upload a SharePoint document to an email.&nbsp;</span></p> <p class="lightbox" data-plugin-options="{'delegate': 'a', 'type': 'image', 'gallery': {'enabled': false}}" style="text-align: justify;"><span style="font-size: 13px;">&nbsp;</span></p> <p style="background-color: #fcfcfc; text-align: justify;"><span style="font-size: 13px;"><strong>That&rsquo;s it!</strong>&nbsp;We appreciate your feedback! Please share your thoughts by sending an email to&nbsp;<a href="mailto:support@mscrm-addons.com">support@mscrm-addons.com</a>.</span></p> <p style="text-align: justify;"><span style="text-decoration: underline;"></span></p>10138