web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Feeding "Populate a MS...
Power Automate
Answered

Feeding "Populate a MS Word Template" output to a variable

(1) ShareShare
ReportReport
Posted on by 31

Hello!

 

I am struggling with the following problem: In the flow below, I am using the "Populate Word Template" Action, which outputs the following:

 

Jhonny_Nassif_1-1685556578483.png

 

When I use the "Create File" (sharepoint) action and feed the output of the "Template" action directly into its "file content" field, it works fine.

 

The thing I am trying to do is feed the output from the "Template" action into a clean array variable first, and then feed the variable to the "Create File" action.

 

The file is created this way, but is corrupted and cannot be opened.

 

Below is a print of the flow:

 

Jhonny_Nassif_2-1685556837191.png

 

It corrupts the document when I replace the "Word Body" with the array variable.

 

Can anyone share some insights on what I am doing wrong?

 

Thanks in advance!

Categories:
I have the same question (0)
  • AWorley Profile Picture
    414 Super User 2024 Season 1 on at

    You need to pass the "content" variable from the body instead of the Body itself, as the content is expected to be a string? 

    I believe the expression would be : outputs('Populate_a_Microsoft_Word_template')?['body/content']

     

    Also when i load that action I do not have access to the body attribute itself but the 

     

    AWorley_0-1685558779130.png

     

     

    Also I noticed that you are passing the Body attribute both in the array value and the Create file. So you may want to do the array value instead of Body. 

  • Jhonny_Nassif Profile Picture
    31 on at

    Thank you, @AWorley , for the fast and insightful reply.

     

    I tried the following:

    Jhonny_Nassif_0-1685561147695.png

    As you can see, I simply renamed the action and used your suggested expression to feed the contents into the string variable.

     

    But, for some reason, the expression outputs blank:

    Jhonny_Nassif_1-1685561303912.png

     

    Which is curious, as the "TemplateM001" action returns the following schema:

    Jhonny_Nassif_2-1685561372460.png

    Can you provide any additional insights?

     

    Thanks!

  • AWorley Profile Picture
    414 Super User 2024 Season 1 on at

    What happens if you just place the output of the template action in the variable out right instead of renaming it to Body/Content? 

     

    Typically templates require several pieces of information to apply the values proper. Appending the content would not typically contain the template schema. 

  • Verified answer
    Jhonny_Nassif Profile Picture
    31 on at

    Tried that before... the problem is that the variable must be STRING in order to be selectable as dynamic content for the "file content" field of the "Create File" action.

     

    And, being a string variable, the output of the "template" action doesnt show up in the dynamic content of the "set variable" action, as the output is seen as an array.

    The point of all this is because I have a switch action that selects a template depending on a FORMS answer.

     

    My goal is to put these templates outputs all in the same variable (depending on which template was selected by the switch) and then have a single "create file" action with the variable, after the switch action,

     

    Instead, I could build one "create file" action for each template inside the switch after each template, but this feels extremally suboptimal. Nevertheless, I feel like this is going to be the way to go, unfortunately...

     

    Thanks very much for the help, and I am more then willing to explore any other suggestions you may have!

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard