4

Is it possible to have "clickable" URL address in (SP 2010) calculated column without any JavaScript code or Designer?

I found the way how to easily make "universal" Document ID links visible for all documents in our portal thru Search Center, because users don't want to remake all links in documents everytime we change company structure. I created site calculated column for Document content type and users can add this column to any view but link inside is text only. No big deal, but and I want more. My code:

="https://portal/sites/search/Pages/results.aspx?k="&[Document ID Value]

Or is there any other way how to bring this URL to users? Thank you.

[edit] Solved, our developer made a feature for us (and yes, it is a kind of script attach to link in context menu after all...). Thank you

1

5 Answers 5

3

We've recently released a free HTML Calculated Column; it acts just like a calculated column, but won't escape HTML:

Pentalogic's SharePoint HTML Calculated Column

To produce a clickable link, you'd use the following formula:

="<a href=\"https://portal/sites/search/Pages/results.aspx?k="&[Document ID Value]&"\">Link</a>"

Disclaimer: I work for Pentalogic; on this project actually. Oh, and I'm afraid you have to sign up for our newsletter, but that isn't a bad trade (in my unbiased opinion). :)

2
  • 1
    Stuart, You remember this case after such a long time :) Thank You. Completely without scripts? Sounds great, we can try it on our test farm. You can't imagine what our users did with scripts in old farm... (It cost 156 overtime hours to repair all damages after migration)
    – Molik
    Jan 12, 2012 at 19:28
  • Signing up for newsletters is a terrible trade off. Apr 30, 2019 at 9:52
7

I tried this in SharePoint 2013 Online but didn't work

="<a href=\"https://portal/sites/search/Pages/results.aspx?k="&[Document ID Value]&"\">Link To Document</a>"

It doesn't like the \". As a workaround use single quotes for the URL as follows

="<a href='https://portal/sites/search/Pages/results.aspx?k="&[Document ID Value]& "'>Link To Document</a>" 

This worked although right aligned because of the number format.

Using Date instead of number makes them right aligned but they don't wrap

2
  • +1 was also using SharePoint 2013 online and was getting an error. Your second solution worked! Feb 16, 2015 at 19:04
  • Greetings! Does it still work for You in SharePoint Online in 2018?..
    – Gennady G
    Sep 20, 2018 at 10:43
4

actually this is much easier than the options above. if you set the data type returned by the calculated column to be Number, then it is interpreted as HTML.

see this link for more details: http://sharepoint.rackspace.com/calculated-columns-tutorial

6
  • Does not work with SharePoint 2013 online, see Ian B's answer for the right solution for SharePoint 2013 online. Feb 16, 2015 at 19:05
  • wha? it's basically the same solution. the key point is that you can put any html you want inside a list view web part row. people should be upvoting this like crazy! it's horrible that people are using a custom solution to do this.
    – Nacht
    Feb 19, 2015 at 12:40
  • The one downside to this method is that it right aligns the cell values and it is doing that with a hardcoded <div align=right> so there is no way to change that through css. You have hack a little jquery to get that realigned, such as this $listviewTbl.find('.ms-vb-firstCell').next().find('div[align="right"]').attr({align: 'left'});
    – Tom
    Sep 6, 2015 at 13:09
  • If I had to guess, I wonder if downvotes were because this is undocumented behaviour, which hence might be removed in a future version and break lists built around it. @Chris: It does work in 2013. Lastly, if you want it left aligned, I think you can use Date/Time format instead. (if memory serves...) Oct 20, 2015 at 12:53
  • There aren't any downvotes on this answer... While that's a good point, It's still a way easier solution to this problem than some custom solution that also may or may not work when 2016 comes along. I think chances are way better they won't patch this out. Unfortunately with SharePoint undocumented features are a way of life!
    – Nacht
    Oct 22, 2015 at 22:11
3

Based on what you describe, it would make more sense to reformat the search results to include the link to the documents the way you describe. By adding a calculated column to every single Document Library, you're incurring unnecessary overhead.

In SharePoint 2007 search (I just haven't looked at 2010, but I'm guessing it's the same), the search results are formatted using XSL, which you can modify to show the link (plus any other metadata) you want.

2
  • Thank you for your answer, but xml change is not what our managers want. We have serious problems with migration from MOSS 2007 to SP 2010 because our content admins inserted scripts or launch designer each time, when they wants something more that SP offered and each customization, even that small, can be problem in the future again. Great situation, because on the other hand, our users don't want to change their links inside documents and wants to quick and easy find document ID (preferably directly from context menu of each document like Check out option).
    – Molik
    Jul 8, 2011 at 7:28
  • You're going to build the wrong solution because of mistakes made by others in the past, but of course that's the hand you've been dealt. The "right" answer is the XSL answer. The only way I know of to have the calculated column's value act as a link is to add script to the page to reformat it. See Christophe's HTML calculated column articles. Here's a recent one: blog.pathtosharepoint.com/2010/06/16/… Jul 8, 2011 at 11:36
2

Do you want to construct a clickable url in the search center?

Then you need to modify the XSLT of the Search Core Results WebPart like Marc said. You can build the following url for instance: http:///_layouts/DocIdRedir.aspx?ID=[DocumentID]. You can reveal the document id with his managed property.

If you want a "clickable" column within a sharepoint list you have several options

  • Modify rendering template of a column. See this blogpost.
  • Create a custom workflow with sharepoint designer to build your dynamic url
  • Create a SPListItemReceiver to build your url field dynamically
1
  • Thank you for your answer, but the same comment as above, our managers don't want that kind of changes. But yes, this can be a solution.
    – Molik
    Jul 8, 2011 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.