How get current custom field value and compare it with the new one after update

Bashar Haydar February 19, 2019

Hi all,

i would like to know if there is a way to catchthe previous/current values selected for a custom field of type check box  or drop-down list with multiple selection.

My case is that i have 5 fields once it's updated a related issue will be created that reflect the new values, for here no problem i used the post-function, but what  i need to send an email to the assignee what changes are done example

filed 1 actions:

   - option1 unselected 

   - option2 selected

thank you.

1 answer

1 accepted

1 vote
Answer accepted
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 22, 2019

Hi Bushar,

So in order to get the old and the new value when you update a custom field, you will need a Custom Listener that will listens for Issue Updated events and the script will look something like 

import com.atlassian.jira.event.issue.IssueEvent

def event = event as IssueEvent
def changeItems = event?.getChangeLog()?.getRelated("ChildChangeItem")
def change = changeItems.find {it.'field' == "Checkboxes"}

if (change) {
def oldValue = change.'oldstring'
def newValue = change.'newstring'
// do something with them
}

Hope that sheds some light 

Thanos

Bashar Haydar March 9, 2019

Thank you Thanos, it works for me

Suggest an answer

Log in or Sign up to answer