Skip to main content
Skip table of contents

Updating a field (ex. label) when checking all issues against a JQL query

This script will set the labels fields to a certain value for all the issues that satisfy a defined JQL query.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.label.LabelManager

// list of elements to consider for matching

def searchlist = ["foo", "bar", "bar"]

def labelName = 'Partner'

def labelManager = ComponentAccessor.getComponent(LabelManager)
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def searchService = ComponentAccessor.getComponent(SearchService)

for (searchItem in searchlist){
    def jqlSearch = "company = $searchItem"
    def parseResult = searchService.parseQuery(user, jqlSearch)
    if (parseResult.isValid()) {
        def searchResult =, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
        searchResult.issues.each{issue -> labelManager.addLabel(user,, labelName, false)
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.