Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Is there another way to get the annotations and fields under the annotations to hide or show without using the ui policies?

lrossy31
Tera Expert

Hello there,

I have been working on hiding or showing certain amount of annotations and the fields under them but is not  working properly consistently.  Is there a client script available to do that?  Here is what I have been doing.

On UI Policy to Hide annotation:

Condition if number of shipping =1

onLoad clicked

execute script if true

document.getElementById("anno1").parentNode.style.display = " ";

execute if false

document.getElementById("anno1").parentNode.style.display = " none";

Will greatly appreciate the help.

4 REPLIES 4

Mark Stanger
Giga Sage

Can you post a screenshot of what you're trying to hide exactly?  I'm not sure what you mean by fields under an annotation because I don't think the system groups fields under an annotation as far as I know.

hey Mark,

Thanks for the response. I understand that the fields are not grouped under the annotations. What I was trying to explain is that when I try to hide the fields in a UI Policy through UI Actions when also having a script to hide the annotations it doesn't work for me and that is why I asked if there is another way to have both done at the same time using an onChange client script with conditional to when I want them to show or hide them.

Can you confirm that the show/hide of the annotation works fine if you just do that on its own?  You could simplify the script a bit by using PrototypeJS like this, but I don't think that's going to make a difference.

$("anno1").parentNode.show();

$("anno1").parentNode.hide();

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

UI Policy scripts are basically client scripts so the DOM statements you are using in the UI Policy will also work in a client script:

document.getElementById("anno1").parentNode.style.display = " ";

document.getElementById("anno1").parentNode.style.display = " none";