- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2025 04:49 AM
Hi Everyone,
My requirement is to hide catalog variables / variable editor / whole section (anyone is fine) for one catalog item in RITM and Task views based on a condition. I created an on load catalog client script applies on RITM and Task view. how to hide the catalog variables / variable editor / whole section ?
I tried g_form.setDisplay('variable_editor', false) // did not work
please pour your insights
Thank you!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2025 04:58 AM
there is no direct way for this.
You will have to use DOM manipulation for this and DOM is not recommended.
If you still want then this will work in client side
Note: Isolate Script Field Should be False for DOM to run
// hide
document.getElementsByClassName('veditor_header')[0].style.display = 'none';
document.getElementsByClassName('veditor_body')[0].style.display = 'none';
// show
document.getElementsByClassName('veditor_header')[0].style.display = '';
document.getElementsByClassName('veditor_body')[0].style.display = '';
Before:
After: when I ran the code it's gone
OR
If you don't want to use DOM then use this
1) add the variable editor in a new form section
2) then use this to show/hide the section. section is hidden variable editor is gone
g_form.setSectionDisplay('variables', false); // use correct section name
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2025 04:58 AM
there is no direct way for this.
You will have to use DOM manipulation for this and DOM is not recommended.
If you still want then this will work in client side
Note: Isolate Script Field Should be False for DOM to run
// hide
document.getElementsByClassName('veditor_header')[0].style.display = 'none';
document.getElementsByClassName('veditor_body')[0].style.display = 'none';
// show
document.getElementsByClassName('veditor_header')[0].style.display = '';
document.getElementsByClassName('veditor_body')[0].style.display = '';
Before:
After: when I ran the code it's gone
OR
If you don't want to use DOM then use this
1) add the variable editor in a new form section
2) then use this to show/hide the section. section is hidden variable editor is gone
g_form.setSectionDisplay('variables', false); // use correct section name
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2025 06:07 AM
Hey @Ankur Bawiskar , Thanks for your reply.
I kept the variable editor formatter inside Request Information section and trying to hide it using g_form.setSectionDisplay('Request Information', false), but its not working. should i use backend name of section ? if so, where can i find it ?
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2025 06:09 AM
section name is name of section with lowercase and space substituted with underscore
so it will be this
g_form.setSectionDisplay('request_information', false)
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2025 05:23 AM
Hi @Madhan007 ,
I tried your problem in my PDI and it is working fine for me please check below code
Create OnLoad Client script on sc_req_item table and add below code
function onLoad() {
setTimeout(function() {
var veList = document.getElementsByClassName('veditor_body');
if (veList && veList.length > 0) {
for (var i = 0; i < veList.length; i++) {
veList[i].style.display = 'none';
}
}
}, 300);
}
Result
After:
Below:
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
