Remove the hyperlink from the Lookup Field on the Form in View Mode


Badge +2

I have a form with a List Lookup control on the form.

In view mode the form displays the value from this Lookup Control, as a hyperlink.

I want to remove the hyperlink from the value and retain the text only, in the Form View mode.

I would appreciate any help extended on this.

Thanks.


14 replies

Badge +9

Hi Ritesh Ratna‌,

You can try

1. Remove Hyperlink from Lookup Columns in SharePoint | Salaudeen Rajack's SharePoint Diary.

2. Use a calculated column and set it to selected value of a drop down and show it only in display form.

3. Create another field and use workflow and update it with the selected value of drop down and show it only in display form.

Thanks,

Lakshmi Narayana C

Userlevel 6
Badge +16

A simple solution could not to show this control when the form mode = "View".

Instead you can use another control showing that information.

You can use the rules of controls to set Visible or Not

Userlevel 5
Badge +14

have a look on this solution https://community.nintex.com/message/61755-re-how-to-remove-or-disable-lookup-hyperlinks-on-nintex-forms-2013?commentID=… 

Badge +2

I had tried this earlier, but it did not work for me.

Badge +2

Thanks Fernando. Your Idea was a hit.

I appreciate your help.

What I have done is -

1. I already had a 'List Lookup' control, named 'TestLookup'.

2. Create added a 'Calclated Value' control called "calcAlternateValue", with the following settings.

3. Create a rule for the "TestLookup" control.

     (Hide the control on "Is Display Mode")

           

4. Create a rule for the Calculated Value control - "calcAlternateValue".

     (Hide the control on "not(Is Display Mode)"  )

5. Save and Publish the form. It's Done.

Badge +2

Thanks Lakshmi.

The solution in the link provided by you, did not actually work.

However, your Idea of using the Calculated Value Control, combined with the idea given by Fernando (as below), has hit the final nail in the coffin. Issue Fixed.

Thanks all the same for your contribution.

Userlevel 5
Badge +14

I'm sure it works laugh.png

have you turned 'Is Display Mode' text within code into reference?

Badge +3

It dint worked for me too.

Userlevel 5
Badge +14

this doesn't give a clue on your setup and problem...

please create new question and describe what exactly you a trying to do and problems/errors you experience.

Badge +2

My solution to this issue is to not actually remove the hyperlink, but just to make sure, the user doesn't end up some place else if she/he clicks on the link. This can be easily achieved by creating a rule that disables the respective lookup control when in view mode.

Badge +7

I realize this is over a year old, but I wanted to add different suggestion.

I really didn't want to have to add additional controls to the form just to show the text in a different way so, I used CSS.

If you give the List Lookup control a CSS class: 

216754_pastedImage_1.png

You can use the following CSS to essentially disable the links:

.goalslist > a {
     color: black;
     text-decoration: none;
     cursor: default;
     pointer-events: none;
}
‍‍‍‍‍‍

I will note that pointer-events is not compatible with all browsers, which is why I included cursor: default. 

Without pointer-events, the links are still clickable so, your end users might get a little confused if they accidentally click the text and are suddenly redirected somewhere else.

Before CSS:

216767_pastedImage_2.png

After CSS:

216768_pastedImage_3.png

Userlevel 5
Badge +14
Without pointer-events, the links are still clickable so, your end users might get a little confused if they accidentally click the text and are suddenly redirected somewhere else.

apart from that, and even if pointer-events are supported, such a styled links are still tab-stop targets. so one still can navigate to a link with keyboard and open it...

Badge +7

That is very true. Thank you for adding that point.

Badge +7

Ok so, taking into account Marian Hatala‌'s point about the links still being tab-stop targets, I decided to use the simpler jQuery solution that Lakshmi C‌ referenced above at this site: 

Remove Hyperlink from Lookup Columns in SharePoint | Salaudeen Rajack's SharePoint Diary

I just added it to my form's custom JavaScript instead of a Script Editor Web Part on the page in the example.

Here's the code I used:

     NWF$('a[href*="RootFolder=*"]').each(function(){
          NWF$(this).after('<span style="display:inline-block;width:100%;">' + NWF$(this).text() + '</span>');
          NWF$(this).remove();
     });
‍‍‍‍

I added the inline CSS to keep the lookup selections as a list since mine were used as checkboxes and had multiple results. You could certainly add this to the Custom CSS section instead.

For my specific situation, I also added the following CSS which will prepend a bullet point and space to each list item in each of the List Lookup controls with the specified CSS Control Class.

.goalslist > span::before {content:"2022  ";}
‍‍‍

My end result now looks like this:

218191_pastedImage_1.png

And since each item is a <span> element and not an <a> the links have been removed entirely.

Reply