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 / Using an image selecte...
Power Automate
Unanswered

Using an image selected via and if expression in Populate a Microsoft Word Template.

(0) ShareShare
ReportReport
Posted on by 8

Hello,

 

I am trying to insert an image in to a picture content control in a Word template using Populate a Microsoft Word Template. I would like to do this via an 'if' expression. If a value in a list equals X insert image 1, or if it equals Y then insert image 2. The images are saved in a SharePoint document library and in the flow via a Get File Content step. The 'if' expression is in the relevant advanced parameters box in the Populate step. As part of debugging I have simplified the 'if' statement so it is not checking a list and will just come out true (1=1)).

 

This is the expression I am using:

if(equals(1, 1), body('Image_1'), body('Image_2'))
 
When building the expression the body('Image_1') and body('Image_2') were added using the Dynamic Content selector.
 
When run, the flow gives an error in this step. It looks like it has retrieved some file content but doesn't recognise it. In the testing run it shows this in the relevant parameter:
"dynamicFileSchema/1080646312": "�PNG\r\n\u001a\n\u0000\u0000\u0000\rIHDR\u0000\u0000\u0000\u001e\u0000\u0000\u0000\u001e\b\u0006\u0000\u0000\u0000;0��\u0000\u0000\u0000\u0001sRGB\u0000��\u001c�\u0000\u0000\u0000DIDATHK��1\r\u0000 \fEA��\t\u001a��\u000e��Y�\u0002���Zk�3>L9ܥ��Kz�F\u001d\u0013\u0010W��]�\u001auL@\\1Z,.q�\u0004.�_b�f�d\\\u0000\u0000\u0000\u0000IEND�B`�",
 

If I remove the if statement and just use body('Image_1') (or 2) added using the dynamic content option it works as intended.

 

Have I misunderstood something basic about using 'if' expressions in this context? I'm failing to understand why body('Image_1') behaves differently when entered directly and as the output of the 'if' expression. Any help very gratefully appreciated. And please accept my apologies if I'm doing something daft or exposing some basic misunderstandings!

 

Some images:

 

Alexanderjk_0-1711534860883.pngAlexanderjk_1-1711534902257.png

 

Categories:
I have the same question (0)
  • Alexanderjk Profile Picture
    8 on at

    Just to add a bit more information:

     

    When I use body('Image_1') directly (not in the 'if' expression) and it runs successfully, it shows this in the test environment for the relevant parameter:

    { "$content-type": "image/png", "

    $content": "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAENJREFUSEvt07ENACAIRUEZ0Ulc0c20t//YHANAcnnUnuuMD1MOd6mj7pIeqFHHBMQVo30Xo0YdExBXjNYfi0tcMYEL3MBLAYOc7hcAAAAASUVORK5CYII=" }

     

    And if I use body('Image_1')['$content'] in the 'if' expression it still doesn't work but shows:

     

    "$content": "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAENJREFUSEvt07ENACAIRUEZ0Ulc0c20t//YHANAcnnUnuuMD1MOd6mj7pIeqFHHBMQVo30Xo0YdExBXjNYfi0tcMYEL3MBLAYOc7hcAAAAASUVORK5CYII=""

     

    So it feels like when it comes as an output of the 'if' expression, the file content is treated as a string and not recognised as a png file.

  • DJ_Jamba Profile Picture
    2,837 Super User 2025 Season 2 on at

    Hi @Alexanderjk 

    Could you post the settings for the Picture column in the library?

  • Alexanderjk Profile Picture
    8 on at

    Hi, thank you so much for responding. 'Picture' is not a column but the name of a picture content control in a Word document. As in the post, when the Image 1 file content is included directly and not in an 'if' expression it successfully inserts the image into Word document. When used in the 'if' expression it does not and the flow gives an error. Sorry if I have misunderstood your question.

  • DJ_Jamba Profile Picture
    2,837 Super User 2025 Season 2 on at

    Oops! No I misunderstood 😏

    The picture field when populating a word document expects the output from a Get File Content action.
    Is that what body('Image_1') (and 2) is?

     

  • Alexanderjk Profile Picture
    8 on at

    Yes, that's right. Image_1 and Image_2 are Get File Content steps.

  • DJ_Jamba Profile Picture
    2,837 Super User 2025 Season 2 on at

    Ok, so can you throw a compose in (before you populate the word doc) and add your expression to the compose, then pass the output of the compose to the Picture field when populating the word doc?

    DJ_Jamba_0-1711632989338.png

     

  • Alexanderjk Profile Picture
    8 on at

    Thank you. When using the compose step I get the same overall error:

     

    "The image is not of type PNG or JPG. Please provide an image of type PNG or JPG.\r\nclientRequestId: d18f013e-f65a-45c6-868f-dc2c87c8e329"

     

    However, with the compose step I get the error even if I don't use an 'if expression' and put e.g. body('Image_1') in directly. It shows this in the test run under the relevant parameter:

     

    "dynamicFileSchema/1080646312": {
    "$content-type": "application/octet-stream",
    "$content": "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAERJREFUSEvt0zENACAMRUHq3wkasIMO2Nl/Wa4C2uTyWmvPMz5MOdyljrpLeqBGHRMQV4z2XYwadUxAXDFafywuccUELvhfYstmuWRcAAAAAElFTkSuQmCC"
    },

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard