Tuesday, August 23, 2016

Custom hyperlink icon column using Flow

Laura Rogers (@wonderlaura) writes awesome end-user SharePoint posts, and recently wrote one which caught my eye – “Custom hyperlink icon column”. The write-up explains how you can add a custom column to a SharePoint list which shows an icon with the use of SharePoint workflows. This got me thinking if this is doable using Flow instead…. and it is :)

I suggest you read Laura’s post first, then go ahead with this one.

image

Note: This only works for SharePoint lists at the moment using Flow, not document libraries

For my scenario I will cover how to add a custom edit icon to a list – which in a modern list view takes you to edit mode in one click instead of two. Wooo!
First, create a new site column of type Multiple lines of text, and make sure it’s set to Enhanced rich text. This allows us to store arbitrary HTML markup in the field. Add this column to your list.

image

Head back to the list a let’s create the Flow which will add the edit icon. If you don’t have modern lists, then go to flow.microsoft.com to get started.

image

As none of the default Flow templates suit our scenario, we’ll start off with a blank one.

image

First add a trigger action when a new item is created in the list. Enter the URL of the site where you have your list, and select your list from the List drop-down.

image

Add a second step to update an item. Use the same URL and list as in the previous step. In the Id field insert the ID which is available as an output from the previous step.

image

And now comes the part where we add the actual edit link. I’m using the edit icon from the Office UI Fabric which is available in a modern list, but you can use any markup.

<a href=https://contoso.sharepoint.com/teams/fruities/Lists/Fruits/EditForm.aspx?ID=##ID##””><i class="ms-Icon ms-Icon--pencil"></i></a>

Replace the ##ID## part with the ID token in the update action similar to the image below, and write it into the site column field you added to the list. We’ll leave all the other fields blank.

image

Save the Flow, add a new item to the list, wait a little while and you have an edit link on your item. Total bliss!

To add the extra robustness, enable management of content types from the lists advanced settings page, and hide the column from edit forms. This ensures accidental removal of the link from happening.

image