banner



How To Change Author On Word Template

You're tasked with creating a custom Word document from data in the CDS, where do you offset? How practise you change the data in the Word document? Well this weblog postal service will show you how to generate a Word document invoice from a template and use Microsoft's own connectors to solve the problem. We will also take a look at making a PDF from the document besides with no third-party costs/information issues involved.

Cat

Where to Kickoff

Firstly, nosotros're going to need four things.

  1. CDS Data
  2. File Storage (I'll be using OneDrive)
  3. Premium Ability Automate License
  4. Microsoft Word

So, we demand Microsoft Word installed, why? Well we need Give-and-take as we're going to generate a Microsoft Give-and-take Template on our organization. This will allow employ to create a template that we can laissez passer data into on Ability Automate, so let'southward start there.

Microsoft Word – Template & Design

If you've never made a Word Template before you volition need to enable the developer features. To practise this follow the steps below:

  1. Open Word
  2. Click File
  3. Select Options
  4. Click Customize Ribbon
  5. On the left column find 'Programmer'
  6. Press 'Add >>'
Word Developer Options

Yous take now enabled the programmer options on your ribbon!

From here we can at present pattern our Word Template, essentially, we're just making an invoice in discussion at the moment. I use tables to separate content easier and I propose you doing the same. Use dummy-data to create a mock invoice (see below equally an example).

Word Invoice Example

Now nosotros accept an case of our invoice we want to open the programmer tab. We want to replace the dummy data with plain-text-content controls. You lot can see the control highlighted below and an case of what it looks like when y'all insert it:

Word Control Highlight

In one case you have added a control in supersede of some dummy-data (such every bit the invoice number shown in a higher place) yous need to click 'Properties' in the Developer > Controls section on your ribbon. This will permit utilize to assign a Title and Tag to this control. See below:

Content Control Properties
Why do we want to do this?

When opening this template in Power Automate it will provide united states with an selection to laissez passer data into this tag. We're effectively naming parameters on our template in grooming for united states of america opening this template in Ability Automate. Add all of these controls and proper name appropriately until you're finished. If you're calculation multiple items and then name them, for example, Item1, Item2 and so y'all know what they represent when in your Flow.

Finalized Word Content Example

Populating the Give-and-take Template (Generic)

We need to add the 'Populate a Microsoft Give-and-take template' activity to our Menstruum. Now, this is where things can fall apart hands. If we're merely using the same document to populate each time, then nosotros can just select the Location, Document Library and File. This volition then give u.s.a. a listing of fields to populate.

Power Automate Word Action Example

With this approach we can but add together the dynamic or static values into the fields and we're populating the template, however, if we're dynamically passing in the Word certificate we need to use the Dynamic File Schema arroyo. This approach is in a seperate section.

Now, once nosotros have populated our values, nosotros can simply create the file with the contents of the output from our Populate a Microsoft Give-and-take template activity.

Completed Document

Populating the Word Template (Dynamic File Schema)

This arroyo requires us to use XML/XPath to target the id of the field and populate information technology. The problem is that the ID'due south can easily change if they're not always the same document, so nosotros need a style of retrieving these ID's.

If you pass the location in dynamically you will end upwards with a view like this:

Dynamic Schema Word Template

The dynamicFileSchema is where you volition populate the template, all the same, you demand to get the ID's for this. To do and so, yous need the XML of the certificate.

Firstly, save a re-create of your Give-and-take Document, modify the file type to .zip then excerpt the contents. This will provide yous with all of the documents used to brand the Discussion Certificate. You then need to open the binder, and so the 'give-and-take' folder and and so open the document.xml file.

At present y'all have the XML document open y'all can detect the ID for the particular you're looking to populate, the example below shows you the ID we would need to populate the Customer Proper noun on the invoice.

XML

Nosotros can at present populate the dynamicFileSchema with the ID and the data we want to pass through. A high level look at the code we volition pass will exist similar to:

An bodily example for our Customer Name field will await like:

{     "218556363": "FlowJoe"    }          

This will target the field via the ID and pass "FlowJoe" into the customer name.

The final outcome will look something like this:

XML Added to Template Example

You can obviously replace "FlowJoe" with the dynamic data of your choice.

From hither yous can create a populated word certificate using the Create File (or the SharePoint culling) and laissez passer the file contents through from the Populate a Microsoft Word template action.

Save File XML

This volition Non work for documents that are generated as a template equally the ID'due south volition continue to alter, To handle this you volition need to open the XML certificate on Power Automate and create a menses that extracts the ID based on the alias.

Creating a PDF from the Template

To generate a PDF from the Discussion Template, you can but save your document into your desired location to generate the populated word document and then apply the Convert File action while Selecting PDF and use the outputs in the Create File (OneDrive)/Create Detail (SharePoint).

Here's an example if we were to apply the Convert file action:

Convert File Example

File Name: outputs('Convert_file')['headers']['x-ms-file-name']

File Content: trunk('Convert_file')

PDF Final

How To Change Author On Word Template,

Source: https://www.flowjoe.io/2021/03/10/a-complete-guide-to-creating-and-populating-word-templates-with-power-automate/

Posted by: morriswitts1986.blogspot.com

0 Response to "How To Change Author On Word Template"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel