Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

show/Hide field with annotation text

Purvi Kotadiya
Giga Expert

I have a field which has help text added via annotation and when I hide field via UI policy/client script Annotation text remains the same. 

 

Can someone help me with how to hide/show annotations on the form based on some condition?

2 ACCEPTED SOLUTIONS

Hemanth M
Tera Sage

Hi @Purvi Kotadiya ,

 

I would avoid annotation if possible(tricky to hide, need DOM methods) and show and hide messages using client/UI policies scripts.

 

//show
g_form.showFieldMsg('fieldname','Message.','info');
//hide
g_form.hideFieldMsg('fieldname');

 

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025,2026

View solution in original post

Tanushree Maiti
Tera Patron

Hu @Purvi Kotadiya 

 

I will suggest you to use g_form.showFieldMsg() & g_form.hideFieldMsg() inside a Client Script / UI Policy script.

This native method ties the help text directly to the field's visibility and state.

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

View solution in original post

6 REPLIES 6

Tanushree Maiti
Tera Patron

Hu @Purvi Kotadiya 

 

I will suggest you to use g_form.showFieldMsg() & g_form.hideFieldMsg() inside a Client Script / UI Policy script.

This native method ties the help text directly to the field's visibility and state.

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Thanks @Tanushree Maiti. It worked