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!  

JSLink allows you to utilize JavaScript to transform how columns in a list are rendered.

I've added the JavaScript file that does the hyperlink transformation to my GitHub Repository which you can download here.  As you can see it's a very simple piece of code.

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 7 with your field.    

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.

The last option in that section is a blank field called "JSLink".  This is where you will put the link to the JavaScript file that will transform the field in my list to a hyperlink.  Note:  In the screenshot that I have ~site in the path.  It's very important that you use the ~site token and then the library and name of your file rather than pasting in the absolute URL.  If you just paste in the absolute or even relative URL you will most likely get a 404 error.  

Click "OK" and you should see your column showing as a hyperlink!


  1. what does the namefiledTemplate mean?

  2. 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!

  3. This is very useful and helped to resolve the issue


Post a Comment