JMWE Cloud: Checkbox Validator
Description
This KB explains how to create a validator for the checkbox field that requires the user to select Yes or No for each option.
Option1 (Yes)
Option1 (No)
Option2 (Yes)
Option2 (No)
Option3 (Yes)
Option3 (No)
Option4 (Yes)
Option4 (No)
Option5 (Yes)
Option5 (No)
Option6 (Yes)
Option6 (No)
Option7 (Yes)
Option7 (No)
Option8 (Yes)
Option8 (No)Here is an example to illustrate the checkbox field options
The goal here is to ensure the user selects either (Yes) or (No) for each set of options.
Instructions
Use the following Jira Expression
let checkBox = issue.customfield_XXXXX;
(!!checkBox && checkBox.length == 8) &&
(
(checkBox.some(it => (it.value == "Option1 (Yes)") || (it.value == "Option1 (No)") )) &&
(checkBox.some(it => (it.value == "Option2 (Yes)") || (it.value == "Option2 (No)") )) &&
(checkBox.some(it => (it.value == "Option3 (Yes)") || (it.value == "Option3 (No)") )) &&
(checkBox.some(it => (it.value == "Option4 (Yes)") || (it.value == "Option4 (No)") )) &&
(checkBox.some(it => (it.value == "Option5 (Yes)") || (it.value == "Option5 (No)") )) &&
(checkBox.some(it => (it.value == "Option6 (Yes)") || (it.value == "Option6 (No)") )) &&
(checkBox.some(it => (it.value == "Option7 (Yes)") || (it.value == "Option7 (No)") )) &&
(checkBox.some(it => (it.value == "Option8 (Yes)") || (it.value == "Option8 (No)") )) &&
) Explanation
Replace
XXXXXwith the respective ID of the checkbox custom field.Line #2 checks the checkbox field, which is not empty and has a length of 8 total options.
Lines #4 - #11 check the value selected for each option.