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

Community site session details

Session Id : +KaJCydHwU/3fZpy2oj3LH
Power Automate - Building Flows
Answered

Use Variable for populating Image Content Control in Word Template

Like (0) ShareShare
ReportReport
Posted on 7 Oct 2019 23:18:42 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? 

I have the same question (0)
  • Community Power Platform Member Profile Picture
    on 24 Aug 2022 at 03:43:01
    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 05 Aug 2022 at 09:28:59
    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 21 Jul 2022 at 09:54:32
    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 09 Oct 2019 at 06:58:18
    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 08 Oct 2019 at 16:16:27
    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 08 Oct 2019 at 06:52:07
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 809 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 711 Super User 2025 Season 2

#3
stampcoin Profile Picture

stampcoin 373 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading started
Loading complete