Mandatory selection of Checkbox options

sola2
Tera Contributor

Hello, 

 

I have created a catalog item with serveral sections containing checkboxes. What I want to archieve is that for each section it is mandatory to check at least one of the check boxes.

sola2_0-1739567665383.png

I came accross an old post https://www.servicenow.com/community/sacramento-snug/catalog-item-sleight-of-hand-mandatory-selectio... which states to set the label as mandatory with a UI Policy and the conditions been that the checkboxes are false.

sola2_1-1739567799574.png

 

However, this is not working for me. Can someone help me with a more updated solution to this issue? Thank you in advance.

1 ACCEPTED SOLUTION

Hi @sola2 ,

 

You may try by creating a 2nd list in a Variable-Set & have a ui policy to control the visibility & mandatory requirement.

 

(1) Nothing selected

DharmaLiyanage_1-1739824003000.png

 

 (2) Tier 1 Ministry Role selected 

DharmaLiyanage_2-1739824051966.png

 

(3) Variable set for 2nd List

DharmaLiyanage_3-1739824168623.png

 

(4) UI Policy

DharmaLiyanage_4-1739824256253.png

 

Hope, this helps 🙂

 

 

 

 

 

 

View solution in original post

6 REPLIES 6

Jon Hogland
Tera Guru

Hi, there are a few different ways you can accomplish this, and all of them rely on client scripts. Here's a very, very simple one that you can adjust, adding nested if's as required.

 

function onSubmit() {
   //Type appropriate comment here, and begin script below

   var box1 = g_form.getValue('boolean1');
   var box2 = g_form.getValue('boolean2);
   var box3 = g_form.getValue('boolean3');

   if(box1== 'false' && box2 == 'false' && box3 == 'false'){
	alert('Please select one of the three boxes.');
	return false;
   }
   else{
	return;
   }
   

 That being said, I'm unsure why the linked article's solution isn't working for you. I'd be happy to help if you'd like to pursue that solution instead. This is a silly idea, but does unchecking 'Reverse if false' change the behavior of your UI Policy?



If I've at all helped, please return the favor by clicking the thumb next to my post. Thanks!

Hello @Jon Hogland 

I tried unchecking the reverse if false option but nothing happens

Hi, did you try to implement the script I posted? 



If I've at all helped, please return the favor by clicking the thumb next to my post. Thanks!

Dharma Liyanage
Tera Guru

Hi @sola2 

Just try this :

Catalog Item:

Label

checkbox1

checkbox2

checkbox3

*** make checkbox1 - mandatory

 

Sample:

DharmaLiyanage_0-1739597906408.pngDharmaLiyanage_1-1739598039321.png

DharmaLiyanage_2-1739598089642.png