Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Use Variable for populating Image Content Control in Word Template

(0) ShareShare
ReportReport
Posted on by 421

I'm using the Word Online (Business) connector and the Populate a Word Template action. I have an image content control on my template. 

 

My image is stored as a list item attachment. I'm using Get Attachments then Get Attachment Content to return the attachment content. Assume I am controlling for just one attachment.

 

I would like to set a variable to the attachment content returned, then use that variable for the image when I set my Word Template image control - Get Attachments expects 0 - n attachments, so creates an apply to each loop for me when I get the attachment content. 

I tried creating and setting an object variable to the data returned from Get Attachment Content, then using that for my image content control - but get the error "The image is not of type PNG or JPG. Please provide an image of type PNG or JPG."

 

If I populate the template inside the apply to each for the returned data from Get Attachments, everything works as anticipated. 

 

Is there a way to set a variable to the desired attachment content? What type of variable, and how do I initialize & set it? 

  • Community Power Platform Member Profile Picture
    on at
    Re: Use Variable for populating Image Content Control in Word Template

    Same problem again. I have used both an array variable and a compose action.

    The output of both is a correctly formed image content string

    {"$content-type":"image/jpeg","$content":"/9j/4QBYRXhpZgAATU0AKg...}

    however I am still receiving the same "The image is not of type PNG or JPG. Please provide an image of type PNG or JPG." error message.

  • FarahF Profile Picture
    2 on at
    Re: Use Variable for populating Image Content Control in Word Template

    Please did you get a solution for this error , i am in the same situation as you

  • Community Power Platform Member Profile Picture
    on at
    Re: Use Variable for populating Image Content Control in Word Template

    any solution to this? Even this solution is not helping in my situation as I have to store the image in a variable based on condition which I am gonna use later. 

  • Verified answer
    v-litu-msft Profile Picture
    on at
    Re: Use Variable for populating Image Content Control in Word Template

    Hi @hilary_stoupa,

     

    Compose should be able to handle many kinds of data types. But variable could only handle specified data types, array, object, string, and so on.

    And the function of Compose nested in the Apply to each works like initialize a variable and append to the variable. Though here is image content, so the output of Compose will be an object.Annotation 2019-10-09 145720.png

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • hilary_stoupa Profile Picture
    421 on at
    Re: Use Variable for populating Image Content Control in Word Template

    Thanks for the help - in this specific scenario, this won't work, because my Flow has additional nesting:

    'The inputs of template action 'Compose_2' at line '1 and column '12076' cannot reference action 'Compose'. The action 'Compose' is nested in a foreach scope of multiple levels. Referencing repetition actions from outside the scope is supported only when there are no multiple levels of nesting.'

     

    But at least I have an idea for how to handle this if I don't have that situation. So - can you tell me why Compose will work here but a variable will not?

  • v-litu-msft Profile Picture
    on at
    Re: Use Variable for populating Image Content Control in Word Template

    Hi @hilary_stoupa,

     

    You can use the Compose to get the attachment content instead of initializing a variable, for example:

    After the Apply to each action, you can get the array by use expression "outputs('Compose')".

    Annotation 2019-10-08 144849.png

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1