Bhubaneswar, Odisha, India
+91-8328865778
support@softchief.com

Generate Word Template Automatically from Dataverse Record in Power Automate and Send as an attachment in email outlook

Generate Word Template Automatically from Dataverse Record in Power Automate and Send as an attachment in email outlook

In this blog you will learn how to Generate Word Template Automatically from Dataverse Record in Power Automate and Send as an attachment in email outlook.

Watch the video below or scroll down to read the steps.

Problem Statement

How to download Word Template automatically without manually downloading the template by user and send the word document as an attahment in email.

The below is the record for which the document template should generate whne the record is created.

Solution

Step 1 : Create a Document Template and Upload It

You have to create a document template and upload it in the system. If you dont know how to create document template Learn Here. Once the document upaloded, note the template name and proceed to next step.

Step 2 : Update Entity Features

Enable the BPF option ad Activity option for the entity for twhich the docuemnt will be generated.

Step 3 : Create a Custom Action

Create a custom action with two inut arguments of type entity reference.

  1. TargetEntity ( Lookup to SSE Customer Agreement entity – this is the entity for which the document will be generated)
  2. Template (Lookup to Document Template Entity)

Add the Action Step and Choose SetWordTemplate from Command Action list and in the property assign the parameters selectedTemplate with Template Argument and Target with TargetEntity argument.

here is a snapshot of TargetEntity Argument.

here is a snapshot of Template Argument.

Step 4 : Build the flow

Now you can build the flow to run and trigger when a new record created of the entity type.

First step is to add trigger to run on new record added.

Second step is to initialize a variable to store template name.

Third step is to List Rows – Get template record by template name

Fourth step is to use a Perform Unbound action and choose custom value and use below expression.

trim(‘sse_CustomSetWordTemplate’)

in the Action Parameters use below code

{
“TargetEntity”: {
“sse_ssecustomeragreementid”: “@{triggerBody()?[‘sse_ssecustomeragreementid’]}”
},
“Template”: {
“documenttemplateid”: “@{first(outputs(‘Get_Template_Record_by_Template_Name’)?[‘body/value’])?[‘documenttemplateid’]}”
}
}

Fifth step is to read note record. use List Row Action with below filter

_objectid_value eq @{triggerBody()?[‘sse_ssecustomeragreementid’]} and isdocument eq true and filename eq ‘@{variables(‘Template Name’)}.docx’

Sixth Step is to Send Email with below code

[
{
“Name”: @{first(outputs(‘List_notes’)?[‘body/value’])?[‘filename’]},
“ContentBytes”: @{base64ToBinary(first(outputs(‘List_notes’)?[‘body/value’])?[‘documentbody’])}
}
]

last Step is to delete create note. use below code to get note id.

first(outputs(‘List_notes’)?[‘body/value’])?[‘annotationid’]

This is the final flow snapshot

Once its done if you test the flow by creating a SSE Customer Template, then it will send an email with attachment.

Hope it helps.

 

Leave a Reply