MS Flow and SharePoint Picture Columns: A Trick

Photo by MockupEditor.com from Pexels & Sharon Pittaway

Article Updated: Mar. 21, 2019

Introduction

A colleague (John Patterson) called me today. He said “Mike, do you know anything about Flow and Picture columns?”.

I said “No”, and he said “Well, I do. Want to see a cool trick?”.

What am I going to say? No?

So here is something I learned today about Flow and Picture columns.

Scenario

Before I get into this, I want to propose a likely scenario when you might need to use this technique.

Your company needs an internal buy and sell list on the intranet. Users add a title, description, asking price, and upload an image. The list to display this needs a thumbnail to show the image.

Setup

The solution John was creating was simple but neat. It involved a SharePoint list with a PowerApps form for data input, and a Flow to process new items. The user would enter some data into the various fields of the form and then attach an image. The Flow would begin, and the attached image URL would then be written back the list in a picture field. Resulting in a list view that showed a thumbnail of the image.

I’m not going through all that in this article. I’ll just touch on the Flow and picture column part.

In my setup I created a custom list. Then I added a Hyperlink column and a Picture Column.

Note: In case you didn’t know, in SharePoint, a Picture column is technically a “Hyperlink or Picture” column type, with the “Format URL as” parameter set to “Picture”.

Flow

The idea behind the flow was simple. I added a Flow that would fire when a new item was added to the list. The Flow would read the first attachment and write it’s URL to the HyperlinkCol and the PictureCol.

Initial Steps

  • When a new item is created
    • Pointed to the site and list
  • Get Attachments
    • Pointed to the site and list
    • Id: ID from “When a new item is created”
  • Initialize Variable
    • Name: AttachmentURL
    • Type: String
    • Value: first(body(‘Get_attachments’))?[‘AbsoluteUri’]

Note: There are probably better ways of getting the first attachment, but this is fine for demonstration purposes.

Update the Item

The last thing we need to do is to update the Hyperlink and Picture, right? The settings should be:

  • Update Item
    • Pointed to the site and list
    • Id: ID from “When a new item is created”
    • Title: Title from “When a new item is created”
    • HyperlinkCol: AttachmentURL
    • PictureCol: AttachmentURL

But:

Well that’s not good.

This is generally the point where you resort to the “Send an HTTP request to SharePoint” action right?

But wait, there’s a trick.

The Trick

In a note above I mentioned that in SharePoint, a Picture column is technically a “Hyperlink or Picture” column type, with the “Format URL as” parameter set to “Picture”. The nice thing about this is that it can easily be switched to a Hyperlink by editing the column.

Then save your flow, exit, return to the editor, and…

BOOM!

Then we just need to set the PictureCol to AttachmentURL, add an item with an attachment, and we are done.

But Mike, the PictureCol is now a hyperlink not a picture?

Oh right, then just set it back to a Picture by editing the column.

Yeah, but Mike, now the Flow will break, or you won’t be able to edit it properly.

Let’s see if it breaks. I’ll add a new item with an attachment:

Nope. Not Broken. What about Flow?

Still there. Perfect.

Conclusion

So the trick is, if you need to deal with a picture column in Flow, set it up as a hyperlink column, work with it in Flow, then set it to a Picture column. Since the two column types are basically the same, it shouldn’t be a problem to switch back and forth when you need to.

If you need granular control over the hyperlink column (i.e. if you need to be able to set the Description and the URL for a link) then you are back to using the “Send an HTTP request to SharePoint” action.

Thanks John!

Author: Mike Hatheway

I'm a husband, father of twins, and a consultant specializing in M365. Generally focused on Teams, SharePoint, and the Power Platform. I hold several Microsoft certifications and I work at Bulletproof Solutions.

23 thoughts

  1. Hi Mike, thanks for the tip, this just what I need, however I am not seeing the option to change the picture column between Hyperlink and Picture when I go to edit column.

    Like

  2. OK – I had added an Image column instead of a HL column. Any ideas how Power Automate can save an image to an image column?

    Like

    1. Jason, do you mean a “Picture” column or the new “Image” column? Picture is just a hyperlink. So you would need to upload a picture to a library like “Site Assets” then supply the URL to that image to the Picture field in the SP List. I haven’t had any experience with the new image column yet.

      Like

      1. Hi Mike, thanks for responding.

        It’s the new ‘image’ column type I was experimenting with. It doesn’t appear in either the create or update item connectors :-(

        I did manage to achieve everything I needed to do by following your instructions and sticking with the traditional pic/hyperlink column type, so thanks for the post!

        Liked by 1 person

  3. Hi Mike,

    I was reading your article and thinking that your tip will solve my problem, as I need to put an image on a Sharepoint list.
    I am a beginner in Power Automate and so I have many doubts.

    I was following your toturial, but I ran into a problem with “Initialize Variable”.

    Looking at the image, could you help me?
    [link removed]

    Thank you so much.

    Like

  4. If I wanted to create a “Classifieds” list that allowed users to upload multiple images of an item they wish to sell, what is the best way to implement? Is it using this method you outlined, but iterating through each attachment and storing the URL into a static number of Image columns? Or do you suggest a different approach, like Document Sets (which I’ve never used and may get lost trying to implement)?

    Like

    1. Tbh, the easiest way I have seen this accomplished is with Microsoft Teams. Create a public Team with a moderated General channel that has the posting guidelines. Then an open channel for classifieds. Each post can have multiple attachments. You can delete or mark as sold with the post title.

      If this needs to be SharePoint you could wait for the Microsoft Lists update with the new image column and the card generator. Then you could have an email link for replies. You may run into people trying to edit other people’s ads though. Permissions can be tricky here.

      For SP right now you’ll probably need a combination of attachments, hidden picture columns, Flow and possibly some view formatting. Along with the permissions issue above.

      I wouldn’t get into doc sets. :)

      Like

  5. Hey Mike,
    I just tried this trick and unfortunately I don’t think it is foolproof…Once you change the column type back to display as a picture and reload the flow, it no longer shows the column. After a minute it showed an error: ‘item/link_column is no longer present in the operation schema. It should be removed before the workflow is re-saved.’
    I don’t think this fix is a working solution…

    Like

    1. It’s like Schrodinger’s SharePoint column. Once you apply the trick it exists as both Hyperlink and Picture, but once you look inside the flow it has to decide to be one or the other and breaks.

      Liked by 1 person

    2. Sara,
      You are 100% correct. I got that message when I tried to resave my flow.

      The trick *will work* if you toggle the Picture column back to a Hyperlink *before* you edit the flow.

      So, if you ABSOLUTELY need this functionality, you would need to ensure that any time the flow has to be updated, in the list, you would need to set the Picture column back to a Hyperlink, then edit the Flow, save the Flow, then set the list column back to a Picture in the list.

      I’m hoping the Image column that was release with the new MSFT Lists functionality starts working in Power Automate so the that can be used instead.

      I’ll try to update the Blog when I get a chance.

      Like

  6. You are a life saver. I can’t believe this works. I have searched everywhere and when I finally gave up on trying to get the send HTTP request to work, I come across this.
    THANK YOU!

    Like

  7. Its works very well with one attachment .. if we have multiple attachments attached its taking only first one any solution for that?

    Like

  8. Hello Mike,
    I ran across this and got stuck at Flow > Initial Steps > Initialize Variable > Value
    It is telling me that “first(body(‘Get_attachments’))?[‘AbsoluteUri’]” when adding as an expression is invalid. I’m probably doing something wrong tho.

    Like

    1. Without seeing it I wouldn’t be able to tell. Make sure you are using the expression tab in the box that pops out. And make sure your Get Attachments action is called “Get attachments”

      Like

Leave a reply to Mike Hatheway Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.