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.

Hide Annotations based on UI policy

DevYadav
Tera Contributor

Hi Community, Good Day,

 

I am stuck in a requirement, the requirement to hide Annotation using UI policy when state is in progress then annotation should not visible. I am using this solution. 

 

image_2025-12-01_163834954.pngimage.png

DevYadav_1-1764589188052.pngDevYadav_2-1764589320414.png

 

 

Thanks

 

4 REPLIES 4

Anand2799
Tera Guru

Hi @DevYadav ,

 

You can use toggleAnnotations() or hideAnnotation method for this.

Anand2799_0-1764589795641.png

GlideForm (g_form) | ServiceNow Developers

 

Thanks

Anand

 

sarah_bioni
ServiceNow Employee
ServiceNow Employee

Hi @DevYadav ,

 

In this case, it might be best to use g_form.addInfoMessage instead of the annotation field. You can manage addInfoMessage through the UI Policy script or Client Script. Could you clarify your requirement for better understanding?

 

Regards,

Sarah Bioni

Ankur Bawiskar
Tera Patron
Tera Patron

@DevYadav 

I think it's not possible to show/hide it using script directly

you need to use DOM manipulation for this

Note: DOM manipulation is not recommended practice

AnkurBawiskar_0-1764590706552.png

// Hide the annotation
$('my_annotation').up().show();

// Hide the annotation
$('my_annotation').up().hide();

Ensure Isolate Script Field for your UI policy is False to Allow DOM

AnkurBawiskar_1-1764590789165.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@DevYadav 

I could see you added annotation in form section

you can show/hide form section in your UI policy "Execute if true" and "Execute if false" script

Give correct section name -> space replaced with underscore

// Hide the section
g_form.setSectionDisplay('test_for_annotation', false);

// show the section
g_form.setSectionDisplay('test_for_annotation', false);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader