How to hide annotation using client script for scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2025 06:19 AM
Hi Team,
I was trying to hide annotation for specific related service. However, it is not working. Please suggest. Related services is a reference field. Isolate script is false and UI type = "All"
//onload client scipt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2025 10:37 PM
the client script which is populating that related_services field, there only you add the logic to show/hide annotation
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-05-2025 05:06 AM - edited 05-05-2025 05:07 AM
I added and now it is going inside if but it is not hiding the annotation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 05:08 AM
to hide it should be set as none
Ensure Isolate Script = False for your onLoad client script
try this
function onLoad() {
var rel_services = g_form.getValue('related_service').toString();
if (rel_services == "67a3e8301b8c62d00b9a11739b4bcba2") {
alert('inside if');
document.getElementById('info1').style.display = 'none';
} else {
alert('inside else');
document.getElementById('info1').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
05-05-2025 05:47 AM
@Ankur Bawiskar I tried with both none and block. it is going inside if but not hiding the annotation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 06:11 AM
Isolate Script = False?
Also can you check by using javascript debugger pressing Ctrl+Shift+Alt+J on form.
Then add your code there and see if it's working by Running the code
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