Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Automatically select checkbox if other checkbox is selected

Filip6
Tera Contributor

Hi there,

I have some difficulties to set up one of the catalog item and I would like to ask for help if possible.

I've created the item with multiple checkbox A, B, C, D, E, F, G

I need to configure this item so when C is selected, checkbox B is automatically selected too or when G is selected, checkbox B and C are auto selected and no editable. 

Each of the checkbox have variables and I tried to create a script to meet my expectation but no luck so far. 

Thanks for your time. 

6 REPLIES 6

Masarrat Siddi1
Kilo Guru

It can be done with client script. Can you please share your script.

 

 

 

 

Thanks

Hi, 

I am afraid I do not have any experience with scripting so far.

Managed to set up all my items by using the Catalog UI Policies only. 

I would like to start using script because it allows you to do a lot more. 

So far the script looks like that:

function onChange(control, oldValue, newValue, isLoading) {
if (g_form.getvalue('var_FarmMapping'), true)
g_form.setvalue('var_BingMaps', true);
}

If C is selected, select B automatically. 

The above it does not work. I found a few suggestions in other topics but no luck o far. 

Thank you. 

Hi there,

Try changing your if condition. The if condition should check / match something, for example:

function onChange(control, oldValue, newValue, isLoading) {
    
    if(g_form.getValue('var_FarmMapping') == true) {
        g_form.setValue('var_BingMaps', true);
    }

}

Also look closely for using getValue and setValue.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Filip6
Tera Contributor

Hi, 

I am afraid I do not have any experience with scripting so far.

Managed to set up all my items by using the Catalog UI Policies only. 

I would like to start using script because it allows you to do a lot more. 

So far the script looks like that:

function onChange(control, oldValue, newValue, isLoading) {
if (g_form.getvalue('var_FarmMapping'), true)
g_form.setvalue('var_BingMaps', true);
}

If C is selected, select B automatically. 

The above it does not work. I found a few suggestions in other topics but no luck o far. 

Thank you. 

B