- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2023 01:28 AM
Hi All,
I'm having a record producer where I am using 2 checkboxes variables ,for both of them I checked mandatory checkbox.
But when I submit the record producer form, even if 1 checkbox is selected then the record is getting submitted. But generally if both are checked then only the form has to submit.
Please let me know what steps are to be taken?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2023 02:14 AM
Hi @Renu9
As you are working with Service Catalog, all the checkboxes are automatically clubbed under options label. To achieve your requirement, you can make use of an On-Submit client script. Please find a snip below for your reference :
Please configure this client script on your catalog item and this should work.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2023 01:40 AM
Hi @Renu9
I think you have not enabled "Selection Required" field while configuring the checkbox variables, you have only done it for the label . Please check on that.
Moreover, you can have an On-Submit client script on the record producer which can check if both the checkboxes are checked or not before the submission is done.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2023 01:42 AM
Hi @Amit Verma
For both checkboxes I have selected "Selection Required" as checked. And also I dint create any label. Directly I could see wording 'options' came and as mandatory. I dint set anything to make the options as mandatory as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2023 02:14 AM
Hi @Renu9
As you are working with Service Catalog, all the checkboxes are automatically clubbed under options label. To achieve your requirement, you can make use of an On-Submit client script. Please find a snip below for your reference :
Please configure this client script on your catalog item and this should work.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2023 03:00 AM
Hello @Renu9 ,
Write Catalog Client Script like below.
function onSubmit(){
//Set the mandatory checkbox variable names and total mandatory count here
var mandatoryVars = 'md,do,pa,pa_c,pt,pharm_d,aprn_cp,aprn_cnm,rn,lpn,ma,phd,lpc,msw,lcsw,ld,crna,mha';
var mandatoryCount = 1;
var passed = forceMandatoryCheckboxes(mandatoryVars, mandatoryCount);
var getType = g_form.getValue('Chcekbox variable name'); //is it a "bug"?
if(!passed && getType == 'bug'){
//Abort the submit
alert('You must select at least ' + mandatoryCount + ' options.');
return false;
}
}
function forceMandatoryCheckboxes(mandatory, count){
//Split the mandatory variable names into an array
mandatory = mandatory.split(',');
var answer = false;
var varFound = false;
var numTrue = 0;
//Check each variable in the array
for(x=0;x<mandatory.length;x++){
//Check to see if variable exists
if(g_form.getControl(mandatory[x])){
varFound = true;
//Check to see if variable is set to 'true'
if(g_form.getValue(mandatory[x]) == 'true'){
numTrue ++;
//Exit the loop if we have reached required number of 'true'
if(numTrue >= count){
answer = true;
break;
}
}
}
}
//If we didn't find any of the variables allow the submit
if(varFound == false){
answer = true;
}
//Return true or false
return answer;
}
and refer the below link.
Please mark my answer as correct and helpful if it resolves your issue.
Regards,
Namrata