cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BlackSnowFlake
Regular Visitor

Populate Word Template: How to use dynamic files (dynamicFileSchema)

Hi,
I'm using the Premium Populate Microsoft Word Template with a PowerApps instant trigger. I want my template file name to be derived dynamically. The connector requires I pass a "dynamicFileSchema" field of type dynamic. I cannot find an example online or in documentation. Can someone please demonstrate how this works? I tried passing JSON and plain-text but it fails.
13 REPLIES 13
Mira_Ghaly
Dual Super User II
Dual Super User II

@BlackSnowFlake

I don't think this is possible to read the template file name dynamically because the connector will need to load the template parameters for you to fill in the power automate flow so I suggest if you have multiple templates is to use a switch case based on a specific parameter to load your template.

 

 

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
RichFunk365
New Member

I found a solution to this but it is quite ugly! Basically, when you add content controls to a document, under the hood, they get a number assigned to them. By using that number with a value in JSON format, I was able to get this to work using the dynamicFileSchema field. To make this slightly less ugly, I first pointed the connector to the file that I wanted to work with, thus exposing the content control fields. Then, I copied the actual name of each content control into the value. Once you have done that, click on the ellipses and peek code. This will give you the output of the number mapped to the field name:dynamicFileSchema1.png

dynamicFileSchema2.png

 

Then switch back to the dynamic location/library/file and use the numbers in your JSON:

dynamicFileSchema3.png

dynamicFileSchema4.png

 

This was not quite the answer I was hoping for but I guess it is better than modifying the flow in each environment and having to remap all your values. I have not yet tried this with image controls or repeating controls.

 

I hope this helps someone as I wasted a good bit of time trying to figure this out and was not finding any answers from the old google machine!

 

Happy Power Automating!

MatthewBrooksST
Frequent Visitor

@RichFunk365 I tried it on a repeat control and did get it to work.  Thanks for the information you gave!  It works great!

How did you compose your filename? I keep getting the error "The request entity's media type 'text/plain' is not supported for this resource.

@MatthewBrooksST thanks for validating the repeater control. I have not tried that but I have been able to get images to work as well.

@owneyjs15 the file name should be straight forward but I suspect you are also using a dynamic SP location and library? If so, this is also a bit tricky. You have to use the id's for these values. You can find the id's by pointing the connector to the SP location and library you want to use and then using "peek code" to see the values. They are listed as the "source" and "drive" parameters.

I'm using a static OneDrive for business location. Only my file name is dynamic. Could you show me how you constructed your variable?

Hi Matthew,

 

Could you please let us know the syntax of repeating controls. Seems like some nesting is required but I am unable to fetch the id for the repeater control.

 

Edit : Can see the repeater control now. It was not properly added in the document template previously .

 

nitintelstra_0-1607671069351.png

 

 

Thanks

 

@RichFunk365 

Thank you for this! Really helpful comment - sucks there is so little documentation on the dynamic word template schema 

4evagooner
New Member

I am new to Power Automate and I am trying to populate a dynamically derived word file. The workaround shown by @RichFunk365 is understandable. My only issue is how to compose the variable for the dynamic filename with a static SP location and library.

 

The trigger is "For selected file" and I want the word connector to refer dynamically to the selected file.

KaiW76
Helper I
Helper I

Hello all,


I'm also new in the area of PowerAutomate and have also directly a problem.
I have a list with a fixed naming scheme, I build these names with the help of a loop based on values of a SharePoint list and then load the corresponding Word template which I then want to fill with the data also stored in the SP list.
How do I manage to fill these 4 fields, since there are over 800 documents, it is unfortunately not an option to work with IF or switch / case and enter the numbers by hand.

The field names are the same in all documents.

 

Thanks for your help in advance.

best regards
Kai

 

VAVILOR83
Regular Visitor

Word Online does not work correctly when a table is included in the template, the data is displayed correctly if the generated document is opened in the browser but the data in the tables is incorrect when downloading it

Anonymous
Not applicable

same

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,322)