Hide Annotations

gaidem
ServiceNow Employee
ServiceNow Employee

I've gotten the element ID and tried doing a .style.display='none'; This seemed like a long shot, so I'm not surprised it didn't work. Does anyone know how to conditionally show/hide an annotation?

Thanks!

Matt

21 REPLIES 21

MB26
ServiceNow Employee
ServiceNow Employee

The Section and Line Separators do not have specific IDs or even good distinguishing attributes to be able to specify a good selector and hide them.
You could always use the custom separator and put in your own HTML, with a unique ID to use in your script. You could look at the HTML source for a current line separator and try to recreate that in a custom annotation with your ID.


Sharee1
Kilo Contributor

Thanks for the idea! I'll try it.


gaidem
ServiceNow Employee
ServiceNow Employee

Awesome! U rock!


Ivan Martez
ServiceNow Employee
ServiceNow Employee

You should be able to use the nextSibling method to hide the annotation. I would use firebug (in FireFox) to see what field is before that annotation and get the id of that field then use nextSibling.

Here is a reference on nextSibling
http://reference.sitepoint.com/javascript/Node/nextSibling

I did something similar here with DOM manipulation
How to change the "Incident" label on the incident form


You could do something like:



var annotation = gel('my_field').nextSibling;
g_form.setDisplay(annotation, false);



imartez



Hi Ivan,

I believe that code requires you to include the table for the gel parameter. For example:



var annotation = gel('table.my_field').nextSibling;
g_form.setDisplay(annotation, false);
[/quote]


However I still get the following error: "id.indexOf is not a function" any idea?