MS Flow and SharePoint Picture Columns: A Trick

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 digital transformation consultant specializing in Office 365. Generally focused on SharePoint, PowerApps, Flow, Teams, and PowerBI. I hold several Microsoft certifications including MCSD: App Builder and MCSE: Data management and Analyics. I work at Bulletproof Solutions.

One thought

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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