Bulk Update the Value of a Custom Field on Jira Issues


Use this script in the Script Console to update the value of a custom text field for all issues returned by a query.


I have a project with many issues. I need to change the custom field value for all the issues in this project. With this script, I can easily bulk change all of these issues automatically.

Good to Know

  • (Cloud) Run as an admin user or as "ScriptRunner Add-On User" to make sure permissions to update are granted.


Jira Jira (7.3 - 7.13)

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter

// issues returned from that JQL will get altered
final String searchQuery = "project = SSPA"

// the name of the custom field to alter
final String customFieldName = "TextFieldA"

// the new value to set
final String newValue = "Love Groovy"

def customField = ComponentAccessor.customFieldManager.customFieldObjects.findByName(customFieldName)
assert customField : "Could not find custom field with name $customFieldName"

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def issueManager = ComponentAccessor.issueManager
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def query = jqlQueryParser.parseQuery(searchQuery)
def results = searchProvider.search(query, user, PagerFilter.unlimitedFilter)

results.issues.each {
    def issue = issueManager.getIssueObject(it.id)
    customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), newValue), new DefaultIssueChangeHolder())
Discovered an issue? Report it here

Suggested for you

Appears in these Collections