Today, I was asked about how to create a lookup to a document or item in a SharePoint form. Sometimes a slightly different solution, using a Hyperlink field can do the trick.
Lookups in SharePoint
Table of Contents
So I created a lookup column and then in the SharePoint Details form. This would look like this:
Not too bad!?
But when I click on that lookup I get presented with one of these ugly dialogs from SharePoint 20XX. That is not what we want.
So how do we create a link that gets us directly to the document that I linked to?
Lookups are limited to display simple fields and fields like links to items/documents are not available. So there isn’t much we can do here. Also Calculated columns do not support the links that we are after.
Hyperlinks to the rescue!
Create a Hyperlink field
So first in SharePoint you can create a Hyperlink field.
The big difference of course between a Hyperlink field and a Lookup is that there isn’t a set number of values that you can select from. But in this case that was fine. The lookup was set as part of a flow in Power Automate anyway.
Update Hyperlink field in SharePoint
We will have to use the SharePoint REST API to do the update, to ensure that we have the description of the the Hyperlink available to us.
First, I’ve created my Hyperlink as shown earlier and I called this HTML URL. Then using the Send an HTTP request to SharePoint I’m going to set the Hyper link property.
Notice that there is no need to used odata=verbose in the Content-Type header. I see many people defaulting to use this verbose switch, but that just makes the update more complicated.
And with the above flow we can fairly easily update our Hyperlink field.