Check if Checkbox Contains a List of Wanted Values


This script can be used to detect when a checkbox field contains a given list of string values. If the condition is met, a wide range of actions can be done, such as updating another custom field or transitioning the issue.


As a Product Manager, I want to be sure that all acceptance criteria has been met when the issue is updated. If all checkboxes have been clicked, then a message can be added to the issue indicating that all of them are completed.


Jira Jira (7.7 - 8.6)

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
import org.apache.log4j.Level
import org.apache.log4j.Logger
import com.atlassian.jira.issue.MutableIssue

// Set log level
def log = Logger.getLogger(getClass())

final fieldName = "CheckBoxA"
final wantedOptions = ["Yes", "No"]

def customFieldManager = ComponentAccessor.customFieldManager
def checkBoxFieldA = customFieldManager.customFieldObjects.find { == fieldName }
def issue = event.issue as MutableIssue

// If checkbox field does not exist, it is not needed to continue
if (!checkBoxFieldA) {

def checkBoxFieldAValue = issue.getCustomFieldValue(checkBoxFieldA)
// If checkbox does not contain values, it is not needed to continue
if (!(checkBoxFieldAValue in List)) {

def selectedOptions = checkBoxFieldAValue?.collect { (it as LazyLoadedOption).value }
def containsAllWanted = selectedOptions.containsAll(wantedOptions)
selected Options string list = $selectedOptions
Boolean check if contains wanted = $containsAllWanted
if (containsAllWanted) {
    // Run the logic that you want to run when the checkbox fields contains all wanted values here
    // For example, all check box options that were selected can be cleared
    def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
    issue.setCustomFieldValue(checkBoxFieldA, null)
    ComponentAccessor.issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
Discovered an issue? Report it here

Suggested for you