Hello Brothers and Sisters
I have custom field "RMC Approvals CHeck", multiselect checkbox
I need a WOrkflowValidation. WHen Status changes to ABC I need to check if ALL options from custom field are selected
I build Validator with script like below
But it does not work. Thereis no any error on logs or anything. I can still change the status even if not all checks are selected. Can u advice where i have a bug here?
Hi @Mateusz Janus,
This should work:
def selectedValues = issue.get("customfield_11770")
def requiredValues = issue.getAvailableOptions("customfield_11770")
selectedValues == requiredValues
Basically, it checks if the list of selected checkboxes matches the list of all available checkboxes.
I'd recommend to use Build-your-own Validator, that is another validator from JMWE.
Field Required Validator checks whether the field is empty, but it is not considered empty even if only one checkbox is checked. So, be careful with it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
def customFieldManager = ComponentAccessor.customFieldManager
def cf = customFieldManager.getCustomFieldObject("customfield_11770")
if (!cf) {
log.warn("Custom field not found")
return false
}
def fieldValue = issue.getCustomFieldValue(cf)
if (!fieldValue) {
return false
}
// Extract option values safely
def selectedValues = fieldValue.collect { it.value }
// Define required list
def requiredValues = [
"CAB Approval",
"Cybersecurity Approval",
"QA Signoff",
"UAT Approval",
"Release Announcement"
]
// Return TRUE only if all required options are present
def allSelected = requiredValues.every { it in selectedValues }
return allSelected
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.