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

I have 3 checkboxes and want only 1 to be selected at the time

asd22
Tera Contributor

Hello.

 

I got 3 checkboxes in a variable set, and i want it only to be available to have 1 selected at a time

My checkbox names are :

check1

check2

check3

 

Is this a client script that is needed?

1 ACCEPTED SOLUTION

Hi,

You can do this via simple ui policy , no code.

In the condition have <checkbox 1> <is> <true>

Using the ui policy actions , clear value of checkbox 2 and 3.

 

Do same ui policies for checkbox 2 and 3

-Anurag

View solution in original post

11 REPLIES 11

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @asd22 

Exact query & solution

https://www.servicenow.com/community/developer-forum/only-one-checkbox-can-be-checked/m-p/2216789

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

i tried this but did not work:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}


if(newValue == true  || newValue == 'true'){

alert("inside if");

g_form.setValue('check1', false);
}

}


if(newValue == true  || newValue == 'true'){

alert("inside if");

g_form.setValue('check2', false);

}
if(newValue == true  || newValue == 'true'){

alert("inside if");

g_form.setValue('check3', false);

}

What error you are getting., Try to add the info message and check step by step.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

not getting any error, just nothing happens