Hide field (element) by sys_id

nealratner
Mega Expert

Has anyone tried (and hopefully succeeded) in hiding a form element by sys_id?   The standard way to hide a form field is:

setDisplay(fieldName, boolean)

But what if I just wanted to identify the field by sys_id '11e7374a4f37f6041fee7fe24210c737'

I am really trying to hide specific annotation fields and embedded lists...ctomasi

11 REPLIES 11

Hi Anurag,



Did you use that in a UI policy?   I have multiple annotation-wrapper fields, so can you try adding a second annotation field and label them differently?   I think you can identify the specific field by the caption.   just wondering if you can confirm...



find_real_file.png


Hello Anurag,



This is extremely important to our project and I am still having an issue.   We have multiple annotations and I need to hid them individually.   I tried assigning an "id" as some other posts have mentioned, but no luck there.   I would really appreciate any help you can offer?   Maybe you can send a screenshot of what you did?   Again, I have to hide more than one, so definitely need a way to identify them individually.



Many thanks!



Neal


I didn't find time to try the individual one mate, ill try to see if i can do something today


-Anurag

Hi Anurag,



I actually just figured it out...



<div id=XXX>Annotation Label</div>


if(condition){


XXX.style.display = 'none';


}



On a semi related note...


Any chance you know how to hide an embedded list? I tried to use the SN Guru method https://www.servicenowguru.com/scripting/client-scripts-scripting/hiding-related-lists-embedded-list...



but I think SN deprecated hasClassName


We are on Istanbul...



I tried



var list = ('div[tab_caption="Soil Sample"]')[0];


          if(list.hasClassName('list_embedded'))


          {


                      list.hide();


          }



SN Guru uses $$ but i just get errors that $$ is not a function



I got error without $ or $$



onChange script error: TypeError: list.hasClassName is not a function function (){var o=i(m,arguments);return l.apply(n,o)}


Hi Neal,



Can you try this



var list = ('div[tab_caption="Soil Sample"]')[0];


          if(list.hasClassName('embedded'))


          {


                      list.hide();


          }


-Anurag