Checkbox is empty variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 06:17 AM
Hi all, I'm working on an instance with a client script hiding empty variables. It seems that checkbox variable has a different behavior, as it is allways an empty or null variable, because wheather it's flaged or not inside catalog form, it does not appear on ticket RITM######### or INC#########.
Any Ideas on how can i get checkbox to appear on ticket from, wheather they are flagged or not?
This is my script...
function onLoad() {
g_form.getReference("u_catalog_item", function(cat){
var gr = new GlideRecord("item_option_new");
gr.addQuery("cat_item", cat.sys_id);
gr.query(function(item) {
while(item.next()) {
if(!g_form.getValue("variables." + item.name) || g_form.getValue("variables." + item.name) == 'self-service')
g_form.setDisplay("variables." + item.name, false);
}
});
});
}
Thanks in advance
- Labels:
-
Service Desk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 06:26 AM
Hi Julian,
If Checkbox is not checked then it's value is 'false'. It is not null.
Similarly if checkbox is checked then it's value is 'true'.
Mark as correct or helpful if it does.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 06:27 AM
checkbox always has a vaue either true or false

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 06:32 AM
Hey,
Using checkbox is tricky business as you expect them to return true or false value, which is essentially of boolean type.
But when you use getValue to retrieve the value, the whole game changes and it returns "true" and "false" as string value.
You can compare them by using == "true" OR == "false"
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 12:33 PM
Ok, some update here. Looks like checkbox automatically creates a label and kind of "embedes" various checkbox inside this label. As the label has no value, my script is not showing neither the label nor the checkbox embeded in ticket form...
Any ideas on how could we sort this out...?