Make at least one checkbox mandatory when there are multiple sets of checkboxes

CatalogCat
Tera Contributor

I have a catalog item with multiple groups of label+checkboxes. Is there a way to make the user check at least one of the boxes in any of the groups? This is easy when we have only one group, but it is possible to make a UI policy that will work across the groups?

1 ACCEPTED SOLUTION

Hi,

you will have to use onSubmit catalog client script and verify that

function onSubmit() {

	var value1 = g_form.getValue('variable_1');
	var value2 = g_form.getValue('variable_2');
	var value3 = g_form.getValue('variable_3');
	var value4 = g_form.getValue('variable_4');
	var value5 = g_form.getValue('variable_5');
	var value6 = g_form.getValue('variable_6');
	var value7 = g_form.getValue('variable_7');
	

	if(!value1 && !value2 && !value3 && !value3 && !value4 && !value5 && !value6 && !value7) {
		g_form.addErrorMessage("Please select at least 1 variabel");
		return false;
	}
	return true;

}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

14 REPLIES 14

Sai Kumar B
Mega Sage
Mega Sage

@CatalogCat 

When there are multiple checkboxes you can check the below in any of the checkbox variables for every set

find_real_file.png

 

CatalogCat
Tera Contributor

That will not work, because that will require at least one checked box in each group.
My requirement is that at least one of the boxes on the whole cat item is checked. Many groups can be unanswered, as long as there is at least one checked box in one of the other groups.

@CatalogCat 

You can write OnSubmit() client script and restrict the form submission by validating the checkboxes.

Kartik Sethi
Tera Guru
Tera Guru

Hi @CatalogCat 

 

For Service Portal (as of Quebec), the best way to make at least one checkbox mandatory in a group of checkbox variables is to add a Label that appears in order immediately prior to the checkbox variables, and then make the first checkbox variable mandatory.

The grouping and mandatory settings will ensure that at least one checkbox is selected

Service Portal will treat the group as a single set and will ensure that the user selects at least one checkbox.

 

Please try this and this will work for you surely.


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik