The CreatorCon Call for Content is officially open! Get started here.

Checkbox is empty variable?

Julian12
Mega Guru

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

4 REPLIES 4

SumanthDosapati
Mega Sage
Mega Sage

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

suvro
Mega Sage

checkbox always has a vaue either true or false

Aman Kumar S
Kilo Patron

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"

Best Regards
Aman Kumar

Julian12
Mega Guru

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...?