Check box variable checking via client script

skirby41
Kilo Explorer

Hi,

 

I am trying to set a checkbox variable in the service catalog to true when you select a certain item.   My code below:

 

if (g_form.getValue('og_name') == 'Onboarding'){
alert(g_form.getValue('active_directory'));
g_form.setValue('active_directory', true);
alert(g_form.getValue('active_directory'));

 

I added the alerts in to see what the value of the variable is before and after.   When I run it, it first comes up false(which is correct) and then after it says it is true (which is also correct).   The problem is the checkbox does not actually check off...

 

Does anyone have any thoughts?

1 ACCEPTED SOLUTION

neetusingh
Giga Guru

Replace your code line - g_form.setValue('active_directory', true); with g_form.setValue('active_directory', 'true');


View solution in original post

3 REPLIES 3

Mark Stanger
Giga Sage

When setting client-side values you're always setting a string of some sort (even though this doesn't make sense for a boolean field).   You should try true in quotes and see if that makes a difference.


neetusingh
Giga Guru

Replace your code line - g_form.setValue('active_directory', true); with g_form.setValue('active_directory', 'true');


skirby41
Kilo Explorer

Thanks, so many little things to remember.   I had tried quotes but I had put True in the quotes not true.