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?
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.issue.search.SearchProvider 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 = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter()) log.debug("Total issues: ${results.total}") 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(documentIssue.id) 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, issue.id, 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.
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"?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the quick response, Jonny. This one-off solution won't work for 183K issues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.