Question

Calculated Hyperlink

  • 16 February 2023
  • 2 replies
  • 209 views

Userlevel 1
Badge +4

I have a hyperlink that appears in a calculated field. Users are unable to click on this hyperlink because it appears as just a line of text like this www.hyperlink.com. How can I make this into a clickable link w/in the calculated field? 


2 replies

Userlevel 5
Badge +14

You can get a Calculated Control to generate a hyperlink by simply using the proper <anchor> element as a return value. 

Example:

 

 

 

If you want to really calculate the URL or Display Text based off of some other controls then you could just use a little function like: 

(function(url, displayText){
return "<a href='https://" + url + "' target='blank'>" + displayText + "</a>";
}("www.google.com", "My Google Link!"))

 

Replacing the input text of “www.google.com” and “My Google Link!” with control names like:

 

(function(url, displayText){
return "<a href='https://" + url + "' target='blank'>" + displayText + "</a>";
}(control_URL, control_LinkText))

 

 

Hope that helps

Userlevel 1
Badge +8

To clarify, if you want the results of a calculated column to appear as a URL, in earlier versions of SharePoint such as 2010, you could set the output of the calculation to “Number”, and if it was formatted as a URL, it would display as such.

This loophole was closed in SharePoint 2019 for sure, and possibly earlier versions.  The only way to have an actual URL column is to build it as such.  If it needs to be “calculated”, its value will need to be set via workflow.

Reply