Only one checkbox should be select?

Sid_Takali
Kilo Patron
Kilo Patron

Hi all, 

I have created two checkbox on a form which are "Accept" and "Cancel".  The only one checkbox should be selected at a time. When I select a "Accept" then "Cancel" should not be select or vice versa.  How can I achieve this? 

SiddharamTakal_0-1664883837779.png

 

 

Thanks!

1 ACCEPTED SOLUTION

Sagar Pagar
Tera Patron

Hi, You can achieve using UI policies.

 

Define 1st UI policy as -

Condition -

Accept is true

 

UI policy Scripts -

Execute if true:

 g_form.clearValue("u_cancel");

 

Execute if false:

 g_form.setValue("u_cancel", true);

 

 

Define 2nd UI policy as -

Condition -

Cancel is true

 

UI policy Scripts -

Execute if true:

 g_form.clearValue("u_accept");

 

Execute if false:

 g_form.setValue("u_accept", true);

 

Please try this and let me know.

 

Thanks,

Sagar Pagar

The world works with ServiceNow

View solution in original post

3 REPLIES 3

Sagar Pagar
Tera Patron

Hi, You can achieve using UI policies.

 

Define 1st UI policy as -

Condition -

Accept is true

 

UI policy Scripts -

Execute if true:

 g_form.clearValue("u_cancel");

 

Execute if false:

 g_form.setValue("u_cancel", true);

 

 

Define 2nd UI policy as -

Condition -

Cancel is true

 

UI policy Scripts -

Execute if true:

 g_form.clearValue("u_accept");

 

Execute if false:

 g_form.setValue("u_accept", true);

 

Please try this and let me know.

 

Thanks,

Sagar Pagar

The world works with ServiceNow

-O-
Kilo Patron
Kilo Patron

You should not be using check-boxes if you want only one thing selected at a time. I mean you would be designing against established computer UI paradigms. You would normally be using radio buttons, however since that is not supported in SN (well, not quite so, but still), you should use a select box.

Mike_R
Kilo Patron
Kilo Patron

I would use a choice field instead. But if you absolutely need the check boxes, you can create a UI policy or client script to enforce only one selection.