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

Mark Stanger
Giga Sage

gaidem
ServiceNow Employee
ServiceNow Employee

Yea, I'm just not smart enough to figure out how to do this 😞


MB26
ServiceNow Employee
ServiceNow Employee

If you are doing an Annotation, and selecting "Custom" Annotation Type, you will be given a text box where you have probably put in some HTML to display. As an example, if you are putting in some HTML like this, give the top most tag an id.



<div id="myid">
<p>This is what I want to display in my annotation.</p>
</div>


Then you can create a client script, with whatever condition you want, to display or not display this annotation.

Client Script - would be an onLoad client script.


function onLoad() {
var mine = $('myid'); //This selects the element with the ID you have specified.

//This if statement would be whatever condition you want.
//I specified if "mine" (or the element selected) is there, run my code.
if (mine) {
//This is a simple way to hide the element selected.
mine.hide();
}
}


Hopefully this helps to see it visually


Sharee1
Kilo Contributor

Can you give a "Line Separator" annotation a name so it can be hidden as well?

I've tried:

div id="ann2"
with the comment out tags around it

but it puts spaces in the middle of the line:

___________ __________________