two mandatory checkboxes on catalog item

phr
Tera Contributor

Hi All,

 

I have a requirement where there should be two mandatory checkboxes on the catalog item form and user on selecting both checkboxes can submit the form.

Even though i have set both the checkboxes to mandatory i am able to submit with  only 1 checkbox .

How to set both checkboxes mandatory?

phr_2-1718360788858.pngphr_3-1718360809707.png

 

 

phr_0-1718360679441.png

phr_1-1718360710420.png

 

 

4 ACCEPTED SOLUTIONS

xylostar
Tera Contributor

There might be a script overriding the mandatory field setting. Try checking the 'Catalog Item Script' section for any onSubmit or onChange functions that might be bypassing the validation. You can also try making the checkboxes 'Dependent' on each other - that way, selecting one will automatically check the other.

View solution in original post

Hi @phr,

 

Please follow this doc below:

https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/product/service-catalog-man... 

 

Please let me know if you need any help. 

 

Please accept my solution if it resolves your issue and thumps 👍 up 

 

Thanks 

Jitendra 

Please accept my solution if it works for and thumps up.

View solution in original post

Dhirendra Singh
Mega Sage

create a simple onsubmit script with last order to run at last with if (firstcheckbox && secondcheckbox)

View solution in original post

SAI VENKATESH
Tera Sage
Tera Sage

Hi @phr 

 

If above scenarios are not working as mentioned by @Jitendra Diwak1 , 

Please write onsubmit client script and abort the submission if both checkboxes are not selected.

function onSubmit() {
    var cbox1 = g_form.getValue('first_field_name');
    var cbox2 = g_form.getValue('second_field_name');
   
    if (cbox1 !== 'true' || cbox2 !== 'true') {
        alert('select both checkboxes to submit the form.');
        return false;
    }
    return true;
}

 

Thanks and Regards

Sai Venkatesh

View solution in original post

8 REPLIES 8

Hi @phr,

 

Please follow this doc below:

https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/product/service-catalog-man... 

 

Please let me know if you need any help. 

 

Please accept my solution if it resolves your issue and thumps 👍 up 

 

Thanks 

Jitendra 

Please accept my solution if it works for and thumps up.

xylostar
Tera Contributor

There might be a script overriding the mandatory field setting. Try checking the 'Catalog Item Script' section for any onSubmit or onChange functions that might be bypassing the validation. You can also try making the checkboxes 'Dependent' on each other - that way, selecting one will automatically check the other.

Dhirendra Singh
Mega Sage

create a simple onsubmit script with last order to run at last with if (firstcheckbox && secondcheckbox)

SAI VENKATESH
Tera Sage
Tera Sage

Hi @phr 

 

If above scenarios are not working as mentioned by @Jitendra Diwak1 , 

Please write onsubmit client script and abort the submission if both checkboxes are not selected.

function onSubmit() {
    var cbox1 = g_form.getValue('first_field_name');
    var cbox2 = g_form.getValue('second_field_name');
   
    if (cbox1 !== 'true' || cbox2 !== 'true') {
        alert('select both checkboxes to submit the form.');
        return false;
    }
    return true;
}

 

Thanks and Regards

Sai Venkatesh