Find out if a JIRA update event changes a specific issue field

I'm using Script Runner and I want to add a listener, that check, if the value of a specifc custom field is changed during this update event.

The custom field name is "Category" and it's id is "10400".

I assume it is somewhere hidden in com.atlassian.jira.event.issue.getChangeLog()". Am I correct? If yes, how can I loop through the changes to identify, if my specific field has changed or will be changed durin this event? Is this some kind of array? An option to visualize could probably be helpful.

1 answer

Hi Nando, 

You can have in your listener that listens to issue updated events, something like the following script 

def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "SelectListA"}
if (change) {
log.debug "Old value : ${change.oldstring}"
log.debug "New value : ${change.newstring}"
log.debug "Value changed by ${event.user} at ${event?.getChangeLog()?.created}"
// do something if the value of the Category field changed
}

Hope that helps, 

Thanos

Hi @Thanos Batagiannis [Adaptavist] I need to perform a same task..need to know if a story is updated and if yes..need to check if the description field (which is not a custom field) is updated. Do you have any leads for this?

 

Also, what does 

SelectListA indicate here

 

and if event is Issue Updated then,

...{event?.getChangeLog()?.created} will be {event?.getChangeLog()?.updated}

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

176 views 0 4
Read article

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