Diary of a SharePoint Developer

Aleem Sheikh (London, United Kingdom)

Remove hyperlink from Lookup column in SharePoint

with 6 comments

For whatever reason if you don’t want users to be able to click on a lookup column in a list, there’s no straight forward method of disabling that link. Here’s the way I disable them in SharePoint 2010, and it wasn’t any different in 2007 either apart from fancy UI.

In the image below, Country is a lookup type of column

 

 Open the list view in SharePoint designer for modification

 

 Select the lookup column item and in the document map bar in the bottom, choose the context menu for “xsl:value-of”, and select ”Edit Tag…”

You will see the “Edit Tag” window

The above XPath “$thisNode/@*[name()=current()/@Name]” when executed, returns the following hyper link tag

<a onclick=”OpenPopUpPage(‘http://servername/_layouts/listform.aspx?PageType=4&ListId={9CF20D94-56E4-426B-AAA3-97CEA2B23570}&ID=3&RootFolder=*’,RefreshPage); return false;”href=”http://servername/_layouts/listform.aspx?PageType=4&ListId={9CF20D94-56E4-426B-AAA3-97CEA2B23570}&ID=3&RootFolder=*”>United States</a>

In order to get the clean value which is in this case “United States”, we need to remove the decoration around it, so we are going to remove everything before ‘>‘ and after ‘<‘ by changing the tag in the Quick Tag Editor to

<xsl:value-of select=”substring-before(substring-after($thisNode/@*[name()=current()/@Name],’&gt;’), ‘&lt;’)” disable-output-escaping=”yes”>

Then press the tick button on the “Quick Tag Editor” to save the modified tag, save the page and view it in browser

Links are gone.

Neat, isn’t it?

Written by Aleem

July 8, 2011 at 4:44 pm

6 Responses

Subscribe to comments with RSS.

  1. [...] Remove hyperlink from Lookup column in SharePoint [...]

  2. [...] Remove hyperlink from Lookup column in SharePoint [...]

  3. thanks for such a nice article. you save my time…………..

    bhushanp

    February 29, 2012 at 11:55 am

  4. Nice!

    Tina

    March 5, 2012 at 8:32 pm

  5. When I follow your instructions and go to edit tag, the existing tag that I see is different from yours. Mine is “”. Am I looking in the wrong place? (I am using SPD 2007)

    I am new to SP Designer so please go easy on me!! :)

    Amanda

    March 13, 2012 at 1:57 pm

    • This solution is intended for SharePoint 2010, but it can be applied in 2007, you will have to work in code view though. I don’t have 2007 installed so I can’t give you a detailed solution.

      Aleem

      March 16, 2012 at 10:37 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.