- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2025 06:53 AM
Hi I have added a annotation to a form using form layout. I now want to restrict the visibility of it so that it only displays when a specific option is selected. It's not possible do do this through a UI policy. How can this be achieved?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2025 07:15 AM
you can use info message to be shown using display business rule using gs.addInfoMessage()
OR
you can use g_form.addInfoMessage() and show it using client script
OR
You can use showFieldMsg() to show messages below your field
I believe I have provided answer to your question and given different approaches and you can enhance it further as per your requirement.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2025 07:06 AM
not possible via UI policy or client script
you will have to use DOM manipulation for this which is not recommended
this script will help you achieve
Ensure Isolate Script = False to allow DOM
Give the correct field name, value to compare and the Annotation ID
var val = g_form.getValue('fieldName');
if (val == "value1") {
document.getElementById('my_annotation').style.display = "none"; // hide it
}
else{
document.getElementById('my_annotation').style.display = ""; // show
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2025 07:12 AM
I see, would you recommend achieving this a different way instead of using annotations & form layout? I have no problem display a text box at the top of the form using business rule but I am facing issues if I want that same text box to display under a specific form field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2025 07:15 AM
you can use info message to be shown using display business rule using gs.addInfoMessage()
OR
you can use g_form.addInfoMessage() and show it using client script
OR
You can use showFieldMsg() to show messages below your field
I believe I have provided answer to your question and given different approaches and you can enhance it further as per your requirement.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 04:54 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader