Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to transit issues via Groovy script (ScriptRunner)? Edited

Please tell me how to change the status for tasks correctly?

issueKey = "TEST-1"
currentStatus = "In Progress"
nextStatus = "Done"

So, the transition "InProgress -> Done" has an id = 900. Community documentation recommends using {{IssueService}}, which is what I am trying to do...

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.MutableIssue

final String ISSUE_KEY = "TEST-1"

int ACTION_ID = 900

def issueService = ComponentAccessor.getIssueService()

// context of the currentUser
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

// getting issue via IssueService
MutableIssue issue = null

def getIssueResult = issueService.getIssue( user, ISSUE_KEY )
if( getIssueResult.isValid() == true && getIssueResult.getIssue() != null )
issue = getIssueResult.getIssue()
return "Issue not found!"

def params = issueService.newIssueInputParameters()

def transitionValidationResult = issueService.validateTransition( user, issue?.getId(), ACTION_ID, params )

if( transitionValidationResult.isValid() == true )
def issueResult = issueService.transition( user, transitionValidationResult )

if( issueResult.isValid() == true )
log.debug "valid. Issue is = ${issueResult.getIssue()}"
return issueResult.getIssue()
log?.warn "error"
return issueResult.getErrorCollection()?.getErrorMessages()
return transitionValidationResult.getErrorCollection()?.getErrorMessages()


and, my result is:
[It seems that you have tried to perform a workflow operation (Resolve) that is not valid for the current state of this issue (TEST-1). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.]

But, an issue TEST-1 haves the status "In Progress" and, this issue have the direct step/link to the "Resolved" status! Btw, i can change the status "In Progress" to "Resolved" manually, via IssueService - i got error.

So, how to transit an issues as correctly?

3 answers

1 accepted

0 votes
Answer accepted

I could not move the task to the next status because it was an ISSUE_CREATED event. That is, at the time of creation of the task - it is not possible to move the task to the next status (but you can do it during the event ISSUE_UPDATED).

def srv = ComponentAccessor.issueService

class ThreadService extends Thread
private def srv = ComponentAccessor.issueService
private def threadUser
private Issue issue

public ThreadService(final ApplicationUser user, final Issue issue)

threadUser = user
this.issue = issue

public void run( )
//Thread.sleep(1000); // delay for indexing
// there we can do transition

if (event.eventTypeId == ISSUE_CREATED)
Thread t = new ThreadService(event.user, event.issue)
t.start() // !!! no join for CREATED event !!!
else if(event.eventTypeId == ISSUE_UPDATED)
//srv.transition( ... )

Hi there,


I think your script looks fine, can I check that the ID 900 is the ID of the next status and not the ID of the transition itself?

I think from memory you need to provide the ID of the target status and not the transition itself.

IssueService issueService = ComponentAccessor.getIssueService();
IssueIndexingService issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService.class);
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
TransitionValidationResult validationResult = issueService.validateTransition(loggedInUserName, issue.getId(),
actionId, issueInputParameters);
if (validationResult.isValid()) {
issueService.transition(loggedInUserName, validationResult);
ComponentAccessor.getIssueManager().updateIssue(loggedInUserName, issue, EventDispatchOption.ISSUE_UPDATED,
try {
} catch (IndexException e) {
// TODO Auto-generated catch block

} else {
Collection<String> errors = validationResult.getErrorCollection().getErrorMessages();
for (String error : errors) {
// Logger.getLogger(error);





Try This, it will work!

And to get Issue object try below:

def issue = issueManager.getIssueObject("DW-903")



final String ISSUE_KEY = "TEST-1"

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

⚡️NEW Group for Confluence Cloud Admins

Calling all Confluence Cloud Admins!  We created a new Community Group to support your unique needs as Confluence admins. This is a group where you can ask questions, access resou...

78 views 2 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you