Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Bulk Changing issues Types via Groovy


I am trying to bulk change issue types via groovy. I have been able to do so but only at a single issue, here is the following script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

def issueManager = ComponentAccessor.issueManager
def constantsManager = ComponentAccessor.constantsManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueKey = 'xx-xxx' 

def issue = issueManager.getIssueObject(issueKey)
def summary = issue.summary
def description = issue.description
def sourceIssuetype = issue.getIssueType().getName()
def targetIssueType = constantsManager.allIssueTypeObjects.find { == 'Task' }

if (sourceIssuetype = 'Bug') {
    issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

 I am hoping to pass a JQL into the script or a bulk amount of issues to change at once. The UI move is very tedious and often times out for us. Any suggestions?

1 answer

1 accepted

0 votes
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 01, 2023

I see you are using issueManager instead of the new HAPI methods.

Perhaps you don't have access to the recent version of Scriptrunner that includes HAPI.

So if you need to use the native JQL searching capabilities, here is how you could write your script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.bean.PagerFilter

SearchService searchService = ComponentAccessor.getComponent(SearchService)
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def jql = '' //specify your jql here

searchService.parseQuery(currentUser, jql)

def jqlParseResult = searchService.parseQuery(currentUser, jql)
assert jqlParseResult.isValid(), jqlParseResult.errors, jqlParseResult.query, PagerFilter.unlimitedFilter).results.each { issue ->
//do your issue operations here

But there is a possibility with this code that you will run out of memory if you try to run it on a very large number of issues.

The better approach would be to use a limited-size PageFilter and run this in chunks.

Another couple of caveats:

1) changing the issuetype on an issue is usually not recommended. This will not take care of migrating the issue to the correct workflow for the new issue type and all other scheme-related adjustments like the "move" operation in the UI does.  The only place I would allow this is if the 2 issue types share ALL the same configuration: same workflow, same issue configs etc.

I am not aware of any single command that can replicate the move operation.

2) your code was missing a critical step of re-indexing the issue after updating it with the issueManager. Your search results would still be based on the old values. You need to also trigger a re-indexing. If you use IssueSearvice instead of IssueManager, you don't need to worry about the index.

Thanks Peter! I was attempting to use HAPI, but it couldn't find any documentation around updating the issuetype via HAPI.




Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 02, 2023

You can still use HAPI to apply your JQL then run normal issue update code inside the search even if issue.update{ } doesn't offer a way to update the issue type (for good reason as mentioned above).{ issue->
//do issue stuff here, and use issueManager.update

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events