Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Ashton Treadway
Contributor
May 6, 2013

Hi:

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

2 votes
Answer accepted
JamieA
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.
May 6, 2013

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.

Ashton Treadway
Contributor
May 7, 2013

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:

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

JamieA
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.
May 8, 2013

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.

2 votes
Henning Tietgens
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.
May 6, 2013

Hi,

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".

Henning

Ashton Treadway
Contributor
May 7, 2013

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

0 votes
Mizan
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.
May 6, 2013

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
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events