Calculated Column as HTML Fix for SharePoint Online
Some of you are probably aware of this old hack to render a calculated column in a SharePoint list as a hyperlink. The hack involves creating a calculated column, typing in your url and making it a number field which forces it to render as html. Easy peasy lemon squeezy right?
Unfortunately, effective June 13th, 2017 Microsoft has disabled this functionality in Office 365/ SharePoint Online. Read it and weep: Handling HTML Markup in SharePoint Calculated Fields
So, what are you suppose to do if you’re on O365 and have used this hack and you find your pretty hyperlinks no longer working?
JSLink to the rescue!
First thing you need to do is figure what column you want to use for your clickable hyperlink. In my case, I just took the built-in “ID” field and made that my link. Once you know what column you want to use, just replace the
On line 14 I am creating a variable to hold the name of my hyperlink. For my example, I just used the ID field value for the name of my link. You can use any value from any column in your list or you can replace this variable with default text such as “Click to View”. Just swap out that variable for whatever text you want to show.
Finally, you’ll need to build out your hyperlink. If you are already using the calculated field hack just take that logic and apply it to the return value on line 16.
Once you have the changes made to the JS file, upload it to your SharePoint environment (I like to put mine in the Site Assets library).
To apply the JS file to your list or library you need to get into the Web Part Properties. You can do this on the list itself or you can create a new page and add your list web part to the page. I prefer to create a new page rather than editing the list because it protects the list just in case something goes wrong.
Simply edit the list web part and expand the “Miscellaneous” section.
Click “OK” and you should see your column showing as a hyperlink!
what does the namefiledTemplate mean?
This is exactly what I've been looking for, but I'm having a hard time applying it to our particular use case (which is more of a 'status icon' situation). Would you be willing to help with that? Can send the specific calculation we were previously using in the column. Thanks so much!
This is very useful and helped to resolve the issue