show/Hide field with annotation text
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Purvi Kotadiya ,
Create on change client script on field as per your requirement
script:
if (newValue == 'test')
{
document.getElementById("annotation").parentNode.style.display="block";
}
else
{
document.getElementById("annotation").parentNode.style.display="none";
}}
Refer below link:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
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');
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025,2026
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
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.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
