Copy Cascading Select value to Single Select field

Rose Cruz November 21, 2016

The Cascading Select field type in JIRA is incompatible with the new Zendesk Integration for JIRA. For this reason we are considering a change back to a single select field. This would affect 183K issues. I've read that the data is different from field to field, and it sounds like its not possible to copy the values via "Built-in Script" from ScriptRunner. Aside from standard bulk-update or workflow post-functions, is there some other way we can programmatically update sets of issues based on the cascading select value, without registering in the issue's change log? 

4 answers

1 accepted

1 vote
Answer accepted
Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 21, 2016

So, updating an issue without affecting the issue history is not well supported by the API.

That said, for a one-off mass-update, you could write a script for the Script Console that did the update. You'd want to get the results of a JQL query, then edit each item in the list.

This fairly naive example demonstrates how you'd take a cascading list custom field value and set a corresponding select list to the value that matched only the first list in the cascading select. You could modify it a bit to find more complex options, depending on what options you have configured for your single select list.

import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.component.ComponentAccessor

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

// edit this query to suit
def query = jqlQueryParser.parseQuery("project = JRA and assignee = currentUser()")

def results =, user, PagerFilter.getUnlimitedFilter())

log.debug("Total issues: ${}")

def issueService = ComponentAccessor.getIssueService()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

results.getIssues().each {documentIssue ->
    // if you need a mutable issue you can do:
    def issue = issueManager.getIssueObject(
    def cascade = customFieldManager.getCustomFieldObjectByName("CascadingSelect") //your cascading select here
    def singleSelect = customFieldManager.getCustomFieldObjectByName("SelectListA") //your new select list here
    def singleSelectConfig = singleSelect.getRelevantConfig(issue)
    def optionsManager = ComponentAccessor.getOptionsManager()
    def options = optionsManager.getOptions(singleSelectConfig)
    def cascadeValue = cascade.getValue(issue)?.collect{it.value}?.getAt(0)?.toString()
    def optionToGet = options.find {it.value.toString() == cascadeValue}

    def inputParameters = issueService.newIssueInputParameters()
    inputParameters.addCustomFieldValue(singleSelect.idAsLong, optionToGet.optionId.toString())
    def updateValidationResult = issueService.validateUpdate(user,, inputParameters)
    issueService.update(user, updateValidationResult)

If you need to reuse this a lot for some reason, you could wrap it up in a Canned Script.

Rose Cruz December 5, 2016

Hi Jonny,

I'm able to get the results of a query. When it comes to updating the field values, I get stuck on this line:

def cascadeValue = cascade.getValue(issue)?.collect{it.value}?.getAt(0)?.toString()

Error is referring to "it.value"... [Static type checking] -  no such property : value for class : java.lang.Object

I've reached out for help from my engineering organization, will follow up with them tomorrow to see if any resources are available.

What if I don't check the value of the fields, and just modify the query for each option individually? How would I say, "for these results, set singleSelect list value to X"?

0 votes
Rose Cruz December 1, 2016

Thanks Jonny. Will look into this and let you know how it goes.

0 votes
Rose Cruz November 30, 2016

Thanks for the quick response, Jonny. This one-off solution won't work for 183K issues. sad 

Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 30, 2016

I think my original example was unclear. I've updated it to more clearly show what I mean. It's only "one-off" in the sense that you'd run it once via the Script Console. It should update all 183k issues (though you might do a test batch first with a very selective JQL query, just to make sure it works as you expect).

0 votes
Rose Cruz November 21, 2016

Just to clarify, I don't want these issue to show as being "last updated" when I make this change, and don't want my name showing up anywhere either.

Suggest an answer

Log in or Sign up to answer