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

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

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?

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

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.

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.

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?

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)

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?!

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

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

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

759 views 2 19
Join discussion

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