Remove Hyperlink from Lookup Columns in SharePoint
Problem:
When we add lookup column to any SharePoint list, it appears with the link to parent item in SharePoint list views. Quite often, end-user clicks on the lookup link and edits parent lookup item by mistake - People get confused which link to click. So we wanted to remove hyperlink from lookup columns in SharePoint 2013 list views.
SharePoint 2013 remove hyperlink from lookup column - No code solution:
Here is how you can remove hyperlink from lookup fields out-of-the-box without any coding and customization efforts.
Using JQuery to remove hyperlink from lookup column:
Lookup columns are pointing to.link something like "http://Site/***&RootFolder=*". So, lets find all Anchor elements of the page with href attributes "&RootFolder=*". and remove remove link of the lookup.
To remove lookup hyperlink from SharePoint list view using jQuery, Follow these steps:
When we add lookup column to any SharePoint list, it appears with the link to parent item in SharePoint list views. Quite often, end-user clicks on the lookup link and edits parent lookup item by mistake - People get confused which link to click. So we wanted to remove hyperlink from lookup columns in SharePoint 2013 list views.
SharePoint 2013 remove hyperlink from lookup column - No code solution:
Here is how you can remove hyperlink from lookup fields out-of-the-box without any coding and customization efforts.
- Go to your list settings, Pick the lookup column. In my case its "Parent Project". In "Edit Column" page, Select "Title" field under "Add a column to show each of these additional fields" Section as highlighted below.
- Now, Edit your list view, Unselect "Parent Project" field and select "Parent Project: Title" field. (You can rename this Title - BTW!)
-
Click "OK" to save the view. That's all! This removes the link from hyperlink columns.
Using JQuery to remove hyperlink from lookup column:
Lookup columns are pointing to.link something like "http://Site/***&RootFolder=*". So, lets find all Anchor elements of the page with href attributes "&RootFolder=*". and remove remove link of the lookup.
To remove lookup hyperlink from SharePoint list view using jQuery, Follow these steps:
- Go to your List view page, E.g. http://portal.crescent.com/Lists/ProjectMilestones/AllItems.aspx
- Click on Site Settings gear, Click on "Edit Page" Menu item
- Click on Add a Web Part link shown on the page, Under "Media and Content" choose "Script Editor" and Click on "Add" Button
- Click on "Edit Snippet" link on the Script Editor Web part and place the below code in it.
<script type="text/javascript" src="http://code.jquery.com/jquery-1.2.6.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('a[href*="RootFolder=*"]').each(function(index) { var link = $(this); $(this).after("<span>" + link.text() + "</span>"); $(this).remove(); }); }); </script>
- Save and Close the page!
To remove Hyperlink from Person or group fields using jQuery, Just replace the Line#4 with:
$('a[href*="userdisp.aspx?ID="]').each(function(index) {
Hi,
ReplyDeleteThanks for your solution, but your solution remove any hyperlink like as Title, any why exist that can exclude some column?
No title column links will have RootFolder=* in their URLs!
DeleteThanks for your Solution, but I add LinkToItem="TRUE" for column that want to hyperlink to view Item, unfortunately disable this hyperlink after your script, can you help me?
DeleteThe first example worked perfectly for me. Thank you!
ReplyDeleteThanks for this. I tried to use it on my SharePoint 2019 classic site and while it did remove the links to the person columns as I was hoping for, it also removed the ITEMS and LIST ribbon tabs. Any thoughts on how to just get the person column?
ReplyDeleteThanks!
Is there any way to drop the link so when the original lookup source is deleted, it will stay in the lookup field?
ReplyDeleteCould this be updated for Modern Lists with JSON Formatting?
ReplyDelete