How to use multiple checkboxes in a catalog item instead of list collector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 01:54 AM
Has anyone had any success in using multiple checkboxes on a catalog item instead of a list collector? The requirement is for the user to be able to select multiple checkboxes which then populates a singular RITM and SCTASK with whatever checkboxes were selected. This is so users can select multiple hardware items.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi Everyone, Good Day !
I am implementing a similar requirement as mentioned above. Instead of using Catalog UI Policy and UI Actions, I have achieved this through a Catalog Client Script. Please have a look at the implementation below:
My Scenario: Checkbox Validation on Catalog Item Form
We need to ensure that at least one certification checkbox (CSA, CAD, CIS) is selected before allowing users to submit a Service Catalog Item. If none of the checkboxes are selected, an error message will appear next to the checkbox fields.
Implementation Steps:
1. Create a Label as 'Certifications' and Checkbox Variables: Create three Checkbox variables: CSA, CAD, and CIS on your catalog item form.
2. Add UI Script for Validation:
Go to Service Catalog > Catalog Items and open your catalog item.
In the Catalog Client Scripts tab, create a new UI Script with Type = onSubmit.
3. Use the Following Script in the Script Field:
function onSubmit() {
// Get the values of the checkboxes (using your field names 'csa', 'cad', 'cis')
var cad = g_form.getValue('csa') == 'true';
var csa = g_form.getValue('cad') == 'true';
var cis = g_form.getValue('cis') == 'true';
// If none of the certifications are selected
if (!cad && !csa && !cis) {
// Show error message on each checkbox field
g_form.showFieldMsg('csa', 'Please select at least one certification.', 'error');
// Prevent form submission
return false;
}
// Allow submission if any certification is selected
return true;
}
Steps to Add the Script:
Go to your catalog item in Service Catalog.
In Catalog Client Scripts, add a new UI Script with Type = onSubmit.
Paste the script in the Script field and save it.
Test the Script:
If none of the checkboxes are selected, the form submission will be prevented, and an error message will be displayed next to the checkbox field.
If at least one checkbox is selected, the form will be submitted as usual and RITM will be created as below:
Hope this is helpful!
Let me know if you have any queries. Happy learning!
Thanks,
Rajesh