Dynamics 365 has long had the ability to populate Word templates, but not without limitations. Now with Power Automate, there is an easier way.
Microsoft Power Automate
has a huge range of functionality and with the help of the native Word
connector, it is possible to take a prepared Word document and populate it with
data from Microsoft Dynamics 365. The main advantage of this method over using
traditional Dynamics 365 templates is that the data can come from any tables
that you reference in your flow and can also be combined with additional data
along the way.
This tip has steps that
are required to create your customized Word document and create a multi-page
report using Dynamics 365 data.
A one-time step that
needs to be carried out is to enable the Developer tab in Word’s ribbon.
1. Go to the File Tab and
select Options/Custom Ribbon, choose the Developer Option and Click OK. Your window should look as shown:
Next start a new Word
document and format as required. In this example, we’re creating a simple table
of contact information:
First Name |
Last Name |
Email Address |
Address |
City |
State |
|
|
|
|
|
|
For each field you want
to populate, you will need to add a placeholder reference via the Developer tab
as shown in the following figure.
1 – Developer tab
2 – References
3 – Design Mode
1. Click the Insert Text
Control button
2. Enter a name of your
choosing in the ‘Title’ box and click OK. Keep this simple – lower case with no
spaces.
3. When all the fields are in place and with their
titles set, you will need to select the entire row and add a Repeating
Section Content Control, as seen below:
Now that the Word
document is ready, you need to upload it so that it can be accessed by Power
Automate. The simplest place for this would be OneDrive for Business, but
SharePoint is another straightforward option as well.
You are now ready to
create the flow to populate your template with data from Dynamics 365. Head
over to Power Automate begin
creating your flow, either from the Flows option in the menu or creating the
Flow. In this tip, you have kept things
simple, with the flow being triggered manually and listing all contacts:
The key part to note is
the initialization of an empty array that we will later be populating with
Dynamics data.
Next, add an Append
To Array Variable action, select your array variable initialized
earlier and enter your text as shown:
You will note that as
soon as you add the first field (First Name in our example), an Apply
To Each loop is automatically created for you; this enables your Flow
to automatically loop through all of the records found in your List
Records action. Ensure that ‘Value’ text is entered cautiously in the
same format as above or you will get an error message.
Now that you have
prepared your data, you are now ready to populate your uploaded Word Document.
When you add a Populate a Microsoft Word Template action, you
will be prompted to browse for the location of the file and once selected, the
references you added earlier will automatically be displayed:
Although each individual
reference is displayed, by clicking the Switch To Input Entire Array button,
you can populate the entire row at once using your array variable:
With the Word document
now containing data, it’s ready to be used; in this case, you are just sending
a simple email with the Word file as an attachment:
And as you can see, the
received document is now populated with all the requested Contact data:
First Name |
Last Name |
Email Address |
Address |
City |
State |
Carol |
Ray-Holmes |
1234 Anywhere
St |
Sacramento |
CA |
|
Joe |
Jones |
3949 Freed
Street |
Cleveland |
OH |
|
Jean |
Stinnett |
4848 St John
Road |
Atlanta |
GA |
|
Remme |
Smith |
2920 Steward
Rd |
Houston |
TX |
Now with a few simple steps, Word documents can be created that can be populated with your Dynamics 365 data. Once a Word file has been created, edits to this file can easily be made and the original file overwritten, making it much easier to maintain than a traditional Dynamics 365 template.
For more tips and tricks follow updates, workshops and consulting services at www.ladyraycomputer.net
No comments:
Post a Comment