Thursday, March 20, 2014

SharePoint 2010 calculated column and hyperlink (no workflows or scripts required)

Often you will get a requirement like this:

Create a calculated column which concatenate the url text with an existing column value.

This seems to be an easy task, except one thing: SharePoint doest not render hyperlink in calculated column by default.

For example, I have a list with 2 columns: Search term and Google Search. Google Search is a calculated column with this formula

 

 

Now, this is what I will get by default:

There are a few ways to fix this problem. Usually people will recommend you to create a Hyperlink column instead and create a workflow to update the Hyperlink value (http://social.technet.microsoft.com/Forums/ar/sharepoint2010customization/thread/32d32e47-3256-4806-8775-c250b6243038) . Or, you can place a script on the page that loop through the HTML nodes and replace the unfriendly html tags with a hyperlink as described here http://practicalsharepoint.blogspot.com/2011/10/dynamic-hyperlinks-in-calculated.html.

But today, I’m going to show you how to trick SharePoint into displaying the hyperlink, and it is going to be very easy.

1. Modify the calculated column and change the returned data type from Single line of text to Number/Currency/Date and Times. Click OK.

2. Go back to the list and be amazed :)

This will also work when you’d like to achieve the same thing with the image tag <img>.

 

No comments:

Post a Comment