Send an email when an issue is created to a user decided by a custom field's value

rsud May 16, 2014

I have a Custom field "Assigned to Group" in which I have the following values:

1. Development

2. Test

3. Requirements.

When a defect is entered, the author has to select a value for this "Assigned to Group" field.

I am looking to associate an email with each of these options and then trigger an email to be sent to that address.

Basically, IF "Assigned to Group" = Development, THEN email rrr@sss.com

3 answers

3 votes
Svante Gustafsson Björkegren
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 18, 2014

Hi Rsud,

You should also take a look at Notification Assistant for JIRA.

It lets you setup notifications based on JQL really easy. You can either let this be event triggered (i.e. check every time e.g. an issue is created) or schedule it. Like Every day @ noon check if somethng important needs to notified.

You can send either email to users, groups or even custom email-addresses or you can send the notifications to Hipchat if you have that tool in house.

Hope that helped!

// Svante

1 vote
Radu Dumitriu
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 18, 2014

For custom "notification schemes", you will need to script that JIRA.

Use ScriptRunner [free], or JJUPIN [paid] (disclaimer: I'm behind JJUPIN).

We have even more, but I don't think it will help you, anyway you can extract some info from it: http://confluence.kepler-rominfo.com/display/TR/Email+Issue+from+Blitz+Actions

1 vote
BenjiI
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 18, 2014

Hi rsud,

Is this all part of a workflow or does an email has to be sent every time the field 'Assigned to Group' changes?

rsud May 18, 2014

Both. The email is to be generated when the issue is first created, and then subsequently each time when the field is changed. Thanks.

BenjiI
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 18, 2014

Hi rsud,

Sending an email when the Issue is created can be done with the script runner plugin. Do the following steps:

1) Install the script runner plugin. This will add some extra post functions to the workflow editor.

2) Add 3 Script Post-Functions (one for each group) to the Create transition of the workflow. Use the 'Send a custom mail' scripted post function for each of these. The condition will be a comparision of the 'Assigned to Group' values.

The advantage of using the script runner plugin is that you don't have to write the code that sends the email, but you only have to create the necessary templates. This will save you a lot of work.

Because only one condition of the 3 post script functions evaluates to 'true' only one email will be sent.

BenjiI
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 18, 2014

Hi rsud,

Sending an email when the Issue is created can be done with the script runner plugin. Do the following steps:

1) Install the script runner plugin. This will add some extra post functions to the workflow editor.

2) Add 3 Script Post-Functions (one for each group) to the Create transition of the workflow. Use the 'Send a custom mail' scripted post function for each of these. The condition will be a comparision of the 'Assigned to Group' values. To summarize each condtion will look something like:

Assign to Group field is updated AND Assigned to Group field == Development

The advantage of using the script runner plugin is that you don't have to write the code that sends the email, but you only have to create the necessary templates. This will save you a lot of work.

Because only one condition of the 3 post-scripts evaluate to 'true' only one email will be sent.

rsud May 18, 2014

This is what I needed. Thank you. However, this takes care of the creation bit...Is there a way to do this beyond the workflow? If the custom field is just changed, without any change in the workflow steps?

BenjiI
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 18, 2014

I was still typing :) The answer is in the next comments... Please ask if you need any help writing the scripts (for the condition fields)

BenjiI
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 18, 2014

In your condition field you can compare the new value with the previous value, because you have access to the current and previous issue objects. The new issue object is called issue and the old one is called originalIssue. More info on reading custom field values in Groovy can be found here:

https://answers.atlassian.com/questions/295018/post-script-to-update-assignee-if-customfield-empty-or-unassigned

I posted a script in this thread that reads out custom field values in Groovy.

Hope this helps?!

Suggest an answer

Log in or Sign up to answer