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

Quyen1
Tera Contributor

Anyone know any fix for this issue? Thank you


MB26
ServiceNow Employee
ServiceNow Employee

It appears that the Aspen release still creates an annotation as another row/cell in the form table. Still yielding no good selector to show/hide OOB. In my very first post on this topic I suggested you create your own. Here is an example of how to do this to show/hide annotations. Really easy...

If you add an annotation to a form, be it the Info Blue box, red box, section separator whatever, instead of merely typing in the text you want, add an extra HTML tag with an ID which will allow you to find the element to show/hide it. For example...

Instead of only typing in the text "Here is the Annotation", type in..


<span id="annotation_1">Here is the Annotation</span>


This "span" HTML element defines an ID, which can be used by code to find it and show/hide it. The client script to show/ hide this would look like this.


//to hide it
$("annotation_1").up(0).hide();

//to show it
$("annotation_1").up(0).show();


Tom157
Kilo Contributor

using $("annotation_1").up(0).hide(); method left a blank line on the form even i'm able to hide it.

How do I eliminate the empty blank line?


MB26
ServiceNow Employee
ServiceNow Employee

Check out my screenshot tests. Since you have not explained where it is on your form, I will assume it is between fields like in my example. I put it in between Configuration Item and Impact Fields. The second screenshot shows using my example code. This actually hides the "TD" cell in the table which does leave a very small space. It does however not leave a large space, but a small one nonetheless. If you want to eliminate that completely you can modify the code be the following.



$("annotation_1").up(1).hide();


This will actually go up one more element to the "TR". which will completely remove the space as in screenshot 3.

Hopefully this answers your question. If not, please provide screenshots yourself and a more detailed explanation.


Tom157
Kilo Contributor

Thank you!