Use Groovy Script Runner to notify a team only once when a value is set on an issue


What's the most elegant way to accomplish the following in GSR:

  1. Keep an eye on the "Needs QA" field, which is a "yes" or "no" choice.
  2. When the "Needs QA" field gets set to "yes", send an email to QA saying "hey, you guys need to look at this issue."
  3. Don't send another notification email to QA about that issue UNLESS "Needs QA" gets set to "no", and then back to "yes" again.

I have a half-assed solution in place using GSR, but I have no clue how to accomplish the "send only one mail per each time "Needs QA" gets set to "Yes"" part.

As a result, QA is getting email for every issue update after "Needs QA" gets set to "yes", because my solution sees every issue update as an update in which "Needs QA" is set to "yes". I want to have the script somehow recognize "oh, I've already sent mail once, I don't need to do it again".

3 answers

1 accepted

For listeners, you can AND your check of the custom field with:

changeItems.any {it.get('field')=='Needs QA'}"

ie, so the value is Yes, AND the value was changed in this transition.

Or move it to a workflow function as Henning says, which will be easier for you and might be more clearer for the users.

You know I love you, but I think Henning's idea is the right one for this application.

However, I still have a stupid question for you!

When formatting the email to be sent, how do I:

  • Properly insert a line break
  • Identify the person who made the last comment

I am currently doing this godawful thing, which provides a working line break but terrifies me:

<% if (componentManager.getCommentManager().getComments(issue)) out << "The most recent comment on the issue was: <p><i>" << componentManager.getCommentManager().getComments(issue).last()?.body %>

I agree Henning's answer is the right way to go ;-)

If using html format you need to use <p> or <br>... if using text format you can just use a newline - "\n".

You may get mismatched tags the way you have it now but shouldn't cause major problems... otherwise just add << "</i></p>" after the .body bit.


what about removing the Needs QA field from the edit screen and make it only editable through a global transition (cyling back to the current status)?

Than you have two possible solutions:

  1. For this transition you can use a new event and for this event you can put QA into the corresponding notification scheme. In this way, QA only gets a notification if the value of this field is changed.
  2. You can trigger an email through Script Runner post function only if the value of the Needs QA field is set to "Yes".


Awesome, Henning. This is exactly the way we want to go.

You will need to check the history of the issue , If the value of "Needs QA" is changed from No to yes then an custom event can be fired , on this event email will be sent to the required group from notification scheme .

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

460 views 8 27
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