- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2018 07:21 AM
I am trying to create multiple CheckBox under a Label and have the CheckBox Mandatory (i.e the user must select at least one CheckBox before submitting). Moreover, is it possible to have a red asterisk next to the label as well?
I was able to get the mandatory CheckBox to work with this tutorial however it does not have the red asterisk that I am looking for.
I am looking for something like this:
On this:
Thank you for the help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2018 11:47 AM
So here are some screenshots...build 2 onChange Client Scripts. This works in the ITIL service catalog, but the Service Portal doesn't seem to like it. Looking at that now:
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2018 08:09 AM
Why not mandatory both check boxes (have red asterisks by both), then create 2 OnChange Client Scripts, one for each check box, that when one of the boxes is checked, the other box is set to "mandatory false".
OnChange Client Script - Example1 variable
var checkboxval = g_form.getValue('variables.example1')
if(checkboxval == 'true'){
g_form.setMandatory('variables.example2', false);
} else {
g_form.setMandatory('variables.example2', true);
}
Something like that
If you want to allow the user multiple choices (a list and they can choose 1 or more choices from it) then you can use a List Collector variable type and just make it mandatory.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2018 11:15 AM
Ok I see what you mean now.
However, I am not familiar with Javascript (I know how to code in C++,C, Java, and Verilog).
This is what I have so far:
function onChange(control, oldValue, newValue, isLoading)
{
if (isLoading || newValue == '')
{
return;
}
//Type appropriate comment here, and begin script below
var checkBox = g_form.getValue('test2');
var checkBox2 = g_form.getValue('test3');
if (checkBox == 'true')
{
g_form.setMandatory('test3', false);
}
else
{
g_form.setMandatory('test3', true);
}
if (checkBox2== 'true')
{
g_form.setMandatory('test2', false);
}
else
{
g_form.setMandatory('test2', true);
}
}
My two checkbox variable names are test2 and test3. When I do test the catalog it does not work (i.e both test2 and test3 are mandatory even if either one is selected). I have a feeling I am missing something with the control, oldValue, newValue, isLoading.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2018 11:30 AM
Let me build it in my DEV instance and see if I can help
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2018 11:47 AM
So here are some screenshots...build 2 onChange Client Scripts. This works in the ITIL service catalog, but the Service Portal doesn't seem to like it. Looking at that now:
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven