We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Hiding SharePoint URL field (spfieldURL) using jquery

Medium Priority
23 Views
Last Modified: 2020-06-22
I am having trouble hiding a SharePoint URL field on an EditForm.aspx.


Client Link   Type the Web address: (Click here to test)
                                     [____________________________]

Type the description: [____________________________]

 

I can hide other controls such as Date picker, People picker, drop-down and single text fields using jquery:

        $('td.ms-formlabel:contains("Start Date")').parent().hide();
      $('td.ms-formlabel:contains("TaskName")').parent().hide();
      $('td.ms-formlabel:contains("Status")').parent().hide();
     
However, this code does not hide the URL field:

        $('td.ms-formlabel:contains("ClientURL")').parent().hide();


Appreciate it if someone could help,

Thank you
Comment
Watch Question

leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
you need to get the right selector
for that, with Chrome for example, right click on the field itself, choose inspect
now on the left panel, your field should be selected, maybe you need to click on its parent to get the exact container you want to hide. you need a unique selector too else you can hide the wrong one
if you need more help, right click on a parent, click copy, copy outerhtml and paste it here

Author

Commented:
Thanks for your reply: I have selected the whole object - the field reference I am using is the FieldInternalName, I cannot see any other references... other than the Input type IDs..




so the jquery that is not working is using $('td.ms-formlabel:contains("DeskSite_x0020_Folder_x0020_ Link")').parent().hide(); 
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
no, what you're showing is acommented HTML, it CAN'T be that
it's just before
if you can't locate it, right click the the full table anc copy/paste the table outerHTML here
your screenshots doesn't help, it just show your interpretation

Author

Commented:
Below is the outerHTML <tr> section where the SP URL control is contained:

<tr>
      <td nowrap="true" valign="top" width="113px" class="ms-formlabel"><span class="ms-h3 ms-standardheader">
      <nobr>Desksite Folder Link</nobr>
   </span></td>
      <td valign="top" width="350px" class="ms-formbody">
      <!-- FieldName="Desksite Folder Link"
          FieldInternalName="Desksite_x0020_Folder_x0020_Link"
          FieldType="SPFieldURL"
        -->
         <span dir="none"><span class="ms-formdescription">Type the Web address:&nbsp;(<a id="Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_$UrlControlId" href="javascript:TestURL('Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_$UrlFieldUrl')" target="_self">Click here to test</a>)<br></span><input dir="ltr" type="text" value="http://Redirect.aspx?FID=2388721" id="Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_$UrlFieldUrl" title="Desksite Folder Link" class="ms-long" style="ime-mode : "><br><span class="ms-formdescription">Type the description:&nbsp;<br></span><input type="text" maxlength="255" id="Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_$UrlFieldDescription" title="Description" value="Open Client page" class="ms-long"><br></span>
       
       </td>
   </tr>
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
do you see the field/element you want to hide here :  https://jsfiddle.net/df9swp83/ 

Author

Commented:
I can see the individual IDs of the input controls, but nothing else referring to 'entire' control (both fields are part of the SPfieldURL control)

 id="Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_ $UrlFieldUrl"  id="Desksite_x0020_Folder_x0020_Link_57383366-b261-4a04-9645-65385ef30c0c_ $UrlFieldDescription"

After some further reading - using SharePoint's 'internal field ID' to hide a control of this type may not be possible, so will likely come down to hiding the 'individual' input fields. Unless there is another way to hide the whole control?
Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Thanks for your help :-)
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
you're welcome!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.