Transition Issue if Assignee field was changed only from "Unassigned"

Sam February 9, 2018

Hi,

I'm new to Script Runner and Groovy and I'm trying to transition issue if Assignee field was changed from "Unassigned" not from "someone" to "someone"

I'm using Script Runner Listener for Jira (Fast-track transition an issue)

For now, my configuration looks like:

Events: Issue assigned

Condition: issue.status.name == 'Open'

Action: "Status Name"

The problem is that configuration works also if Assignee field was changed from "someone" to "someone"

Frankly, I don't need to specify the status name in the condition field. I need to fire the script only if Assignee was Unassigned.

Thank you for any suggestions

 

1 answer

0 votes
Thanos Batagiannis _Adaptavist_
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.
February 12, 2018

Hi Sam,

So if you want a condition that it will return true only if the assignee changed from unassigned to someone else then the script for that should be 

import static com.atlassian.jira.issue.IssueFieldConstants.*

def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == ASSIGNEE}
change && ! change?.oldstring

Hope that helps, 

Thanos

Sam February 12, 2018

Thank you Thanos! I will check your solution soon.

I got also the solution from Aidan [Adaptavist]

import com.atlassian.jira.component.ComponentAccessor //Grab necessary Componentsdef changeHistoryManager = ComponentAccessor.getChangeHistoryManager()//Get last changed itemdef lastChangedItem = changeHistoryManager.getAllChangeItems(issue)[-1] //Looks at end of list if(lastChangedItem.froms == [:]){    return true}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events