Script Runner condition for issue description

I am writing a condition for script runner for JIRA that will look at the description of the issue and if the description has changed since the last change, it will evaluate false. Meaning, if the description was changed to trigger the issue updated event, it will evaluate false, or not fire.

Here is what I have, and it doesnt seem to be working.


if ( == 'P1' && != originalIssue.priority && == 'Risk'  && == 'Open' &&
    issue.getDescription() == originalIssue.getDescription() &&
    com.atlassian.jira.issue.attachment.Attachment == false
    return true

The rest of the code works, up until the description piece. Any advise or pointers are appreciated.

2 answers

Hi Alex,

So in a script listener in order to check if the update was cause by a change to a specific field, let's say description, you need something like 

import com.atlassian.jira.issue.IssueFieldConstants

def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == IssueFieldConstants.DESCRIPTION}
if (change) {
    log.debug "Old value: ${change.oldstring} "
    log.debug "New value: ${change.newstring} "
    return true

hope that helps.

regards, Thanos

It does, but could you explain to me the portion of code between def and the opening curly brace?

One of the objects are returning null, by using the safe navigation operator ?

What the change actually does is checking the fields that changed during the issue updated event and if one of those is the description then ...

In case you want the JAVA API for the above, the event is of type IssueEvent, the getChangeLog is a GenericValue and the getRelated("ChildChangeItem") will return to you a List<GenericValue> and the IssueFieldConstants is order to get the id of the field description (you could use it.field = "description").

I missed the safe navigation operator before find (I updated it). Yes we use the null safe operator because 

The IssueEvent object thrown as a result of an edit operation, may now return null from a getChangeLog() call. This can occur when a user chooses to edit an issue but only leaves a comment and makes no other changes to the issue.


Hope that makes things more clear .


Much more clear.. Thank you very much.

Just need to figure out why it's throwing error for:


Cannot invoke method getBindings() on null object

Trying to get this section you sent me regarding the description changes to work before I add my other conditions back in, but this is continuously giving me the message:


Cannot invoke method getBindings() on null object


import com.atlassian.jira.issue.IssueFieldConstants
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Description"}
if (change) {
    log.debug "Old value: ${change.oldstring} "
    log.debug "New value: ${change.newstring} "
    return false


Any additional thoughts?

is it getChangeLog() or getRelated("ChildChangeItem") that's causing the null object error?


Because I can assure you there is data in the field.

Hi Alex,

So first thing,

You want to use this in a listener or a post function and is it a custom or one of the provided ?(actually If you could paste a screenshot it would be great)

Which version of ScriptRunner and JIRA you use ?

In the script you sent you have find {it.field == "Description"} where it should be

def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == IssueFieldConstants.DESCRIPTION}
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "description"}

(even though this does not cause a Cannot invoke method getBindings() on null object)

cheers, Thanos

JIRA - 7.1.2

SR - 4.3.15


I am using the custom email listener.


I have tried it with both of the syntax you provided. I will take a couple screen shots and upload them to this thread.


Thanks for getting back to me.



@Thanos Batagiannis [Adaptavist]  

May I know how to check the same for a custom field using 


Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in United States

Topic Tuesday: What's your favorite topic?

Good morning All, Our goal is to get you into the habit of while enjoying your favorite morning drink you are checking the NOVA "space" for topics and comments. Your input is really needed and...

36 views 4 0
View post

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