Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Groovy function to check whether given field is updated

Heshan Manamperi
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.
December 7, 2018

I need to check whether the value of JIRA field has been updated or now. The field can be a text field or drop down

if (field value is updated)

      do something

else

     nothing

 

how can I achieve this?

 

2 answers

1 accepted

0 votes
Answer accepted
Heshan Manamperi
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.
December 17, 2018

 

Hi All,

Following code block works for me. Thanks all for the suggestions. 

def isOriginalEstimateChanged = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Custom Data1"}
if (isOriginalEstimateChanged != null)
{
EventDispatchOption.ISSUE_UPDATED, false);
tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), event.getUser().getDisplayName()),changeHolder)
}
0 votes
Joshua Yamdogo @ 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.
December 12, 2018

Hi Heshan,

Are you using ScriptRunner for Jira server?

It depends on what you want to do when the Jira field is updated. With ScriptRunner, you could set up a Script Listener that listens for updates to issues and then check to see if a specific field has been updated. See docs here: https://scriptrunner.adaptavist.com/latest/jira/listeners.html

You could also use ScriptRunner behaviours. For example: if someone is creating an issue and sets a field to some value, you can have the behaviour react and do something to another field. See docs here: https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html

You have a lot of different options, but it depends on what specifically you want to accomplish.

Regards,

Josh

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events