How do you change the assignee during a workflow transition using Script Runner?

I have a workflow transition that looks up the last person in a praticular group (in this case the developer) that worked on an issue.  It then should assign this to the developer as part of the workflow transition.

However, while it looks like the update takes, it isn't reflected in the actual workflow status.

I've tried both this:

def issueService = ComponentAccessor.issueService;

def issueParams = new IssueInputParametersImpl()
issueParams.assigneeId = lastDeveloper;

def updateResult = issueService.validateUpdate(user, issue.id, issueParams)
log.debug updateResult.errorCollection
if(!updateResult.errorCollection.hasAnyErrors()) {
    issueService.update(user, updateResult)
}

And using the assign version:

def issueService = ComponentAccessor.issueService;

def issueParams = new IssueInputParametersImpl()
issueParams.assigneeId = lastDeveloper;

def assignResult = issueService.validateAssign(user, issue.id, lastDeveloper)
log.debug assignResult.errorCollection
if(!assignResult.errorCollection.hasAnyErrors()) {
    issueService.assign(user, assignResult)
}

 

The history shows the change but the bug doesn't actually reflect it.

1 answer

1 accepted

1 votes

If you do it like this you need to make sure it's the last post-function. Is it? 

It's easier just to use:

issue.setAssigneeId("jbloggs")

as the first post-function.

Apparently the key is to use the passed in issue as a MutableIssue, and just don't call store.

Yes. Store is redundant, because the same issue is saved in a later function. The problem with your method, is that I'm guessing you had your function first, and it although it did the job, the later function saved the original assignee again.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,026 views 12 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot