Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Sam
Contributor
February 9, 2018 edited

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
Contributor
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
loom essentials certification, loom training, get certified in loom, atlassian certification, loom async video, video messaging skills, atlassian learning, loom for teams, online certification, loom badge, loom for business, atlassian education

Get Certified in Loom! 🧑‍🎓

Time to up your Loom game! The new Loom Essentials Certification is here! Show off your skills, learn pro tips, and get officially recognized. Perfect for taking your video messaging to the next level.

Learn more
AUG Leaders

Atlassian Community Events