How to hide "options" in a checkbox variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2021 10:06 AM
Dear community, I need help:
I have created a service where I use the checkbox variable:
When I go to the catalog I see that this variable has a default value "options" that I want to delete, but I don't know how to do it.
I read an article in ServiceNow community where they said that you have to create a client script and add the sys id of the variable, but for some reason it does not work:
Any hints?, can anyone help me with this or tell me what mistake I am making?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2021 10:10 AM
Hi,
You have to write an onLoad client script after you create a label to hide it.
$('label_IO:7817abedad4c3100dd49a5edb9ba2a38').hide(); //Replace this with the sys_id of the label you created.
NOTE: To hide a label first you have to create a label and then write a client script to hide it.
Regards,
Sai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2023 11:30 AM
To do this without DOM manipulation (if you're okay with a slight white space where the 'Options' string once was), you can create a label variable and do the following:
g_form.setLabelOf('hide_me_0','');The Question field is mandatory on labels, but this will let you hide the label value without hiding the checkboxes. setVisible and setDisplay on the labels hides all the associated checkboxes as of the Tokyo version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2023 09:41 PM
Hey David,
Where should I apply the below:
g_form.setLabelOf('hide_me_0',''); I'm experiencing the same issue. I've tried to put my variables in a container as well as tried Client script but it doesn't seem to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2023 10:25 AM
Hey sorry for the delay in response. Came back to this to try and remember how I did it.
This is in an onLoad client script. This does not work in native view, but will work in portal:
function onLoad() {
// Hiding the labels to achieve the label-less checkboxes underneath the country selection
// This doesn't work. Hides all the checkboxes.
// g_form.setVisible('hide_me_0', false);
// g_form.setVisible('hide_me_1', false);
// This also doesn't work. Hides all the checkboxes.
// g_form.setDisplay('hide_me_0', false);
// g_form.setDisplay('hide_me_1', false);
// This works but leaves a space between the checkboxes and the master label/container
g_form.setLabelOf('hide_me_0', '');
g_form.setLabelOf('hide_me_1', '');
}Make sure UI Type is set to All or Mobile/Service Portal. There's probably a way to do it on the SC view as well but I haven't encountered that requirement. Might require DOM manipulation for that.
