How Can I Hide a Checkbox?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 09:56 AM
How can I hide a checkbox field in a catalog task?
I’m currently using the code: g_form.setVisible('variable', false);
This works as expected when the variable type is "Yes/No," but it doesn’t seem to work for a checkbox field, which I prefer because it looks cleaner on the form. Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2025 12:37 AM - edited 03-06-2025 12:37 AM
g_form.setDisplay('your_checkbox_variable', false);
if above does not work then try hiding using CSS
g_form.getControl('your_checkbox_variable').parentElement.style.display = 'none';
✔️ If this solves your issue, please mark it as Correct.
✔️ If you found it helpful, please mark it as Helpful.
—
Shubham Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2025 01:02 AM
it should work fine with checkbox variable as well.
please share your complete script
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
03-06-2025 01:29 AM
Hi @bahdol5098
It should work. I tried reproducing your issue and for me, it works as expected. Refer below screenshots where I am hiding a checkbox field 'AI' on a SC task using an On-Load Client Script.
Could you please share your script to assist you further? Also, check if you are passing the right variable name g_form method.
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2025 01:33 AM
It should work for checkbox variable type as well.
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.