- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 04:01 AM
Hi,
I am a newbie and not too good in scripting.
I am creating a Catalog item and there I have 2 check boxes, I want that only one can be selected at a time.
I know this can be done if I create radio buttons but I have been specifically asked to create checkboxes.
This is the onChange Client Script on function variable.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == true){
g_form.setValue('menu','false');
}
This is the onChange Client Script on menu variable.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == true){
g_form.setValue('function','false');
}
Can anyone help with the script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 05:56 AM
Last try,
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == true || newValue == 'true'){
alert("inside if");
g_form.setValue('menu', false);
}
}
//this is onchange client script on menu variable
if(newValue == true || newValue == 'true'){
alert("inside if");
g_form.setValue('fuction', false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 04:11 AM
The variable type - multiple choice creates radio buttons. this can be used to select only one option at a time.
link - https://docs.servicenow.com/bundle/london-it-service-management/page/product/service-catalog-management/reference/r_VariableTypes.html#d198680e1058
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 04:21 AM
Hi,
I do not want radio buttons. I have been specifically asked to create checkboxes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 04:33 AM
In that case, you can use UI policies to restrict values into the other checkbox
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 04:30 AM
I would agree with Rad that the multiple choice is the optimal way of getting to this point, but if, for whatever reason, checkboxes are required, you'd probably need to write a catalog client script onChange of each checkbox where if newValue=true, then set the value of all other checkboxes to false.