Notification Based on Generic Event
Asked by Sharon Porat:

Hi,

I would like to send a notification when specific fields are updated (and not any update event) for example only Priority changed to Urgent or Red Alert, if it was changed to medium or high, don't send an email.

I tried to create a custom event and add it to the notification scheme, but no email was sent.

I would appreciate your advice.

Thanks in advance,

Sharon


Answers:
author: Rilwan Ahmed
body: Hi [@Sharon Porat](/t5/user/viewprofilepage/user-id/5061904) ,

Welcome to the community !!

In the native Jira server, you cannot achieve the requirement. You can make use of [Automation for Jira](https://marketplace.atlassian.com/apps/1215460/automation-for-jira?tab=overview&hosting=datacenter) add-on to achieve this.

i.e. When == Issue updated

If == Add JQL condition

Then == Send Email

To know more about available triggers, conditions, actions go through <https://confluence.atlassian.com/automation/components-in-jira-automation-1141480614.html>

comments: author: Sharon Porat
body: Hi, Thanks for your answer.  
I tried to fire an event with Automation for Jira (that will send the notification) because the mail function is not available to our version (we are still using the Jira server and not Jira cloud)

However, I tried to use ScriptRunner to send an email, but it send a custom mail and not a "Notification mail" that highlights the changes that were made


author: Alex Koxaras _Relational_
body: Hi [@Sharon Porat](/t5/user/viewprofilepage/user-id/5061904) and welcome to the community,

You can't do per se what you ask in the sense that notifications are being sent to specific events and not on CF updated events. If you want to use the notification scheme to do that, then what I propose to do is:

* Make your fields readonly
* Add self transitions to edit these fields
* On these transitions instead of firing the generic event, fire your event
* On your notification scheme add who ever you want to get notified when the above event will fire

Let me know if that helps.

comments: author: Sharon Porat
body: Hi, thanks for your answer.

it's worked. however, I am not sure it can be part of the daily process. I don't want to add a new transition for editing an item, it won't scale


author: Alex Koxaras _Relational_
body: [@Sharon Porat](/t5/user/viewprofilepage/user-id/5061904) this shouldn't be a part of you daily process. I don't quite understand that to be honest... why this should be a part of your daily process? This should clearly be a part of your jira solution.

The scalability thing you mention fails from your own foundation. You can't be serious about thinking scalability when you add such micro management to your solution in Jira. Perhaps the thing you are asking can be done (and be scalable as well) to other platforms. But since you are dealing with Jira and since the latter doesn't have such granularity, it will have huge maintenance.

You could add jira automation rules (and have hundreds of them if you want) and add as trigger "when field change" then send email to specific users.

But again the above will increase your maintenance. You get my point?


author: Sharon Porat
body: Hi [@Alex Koxaras _Relational_](/t5/user/viewprofilepage/user-id/4150197) ,

The goal is to reduce irrelevant notifications. i.e. not every update event is interesting and should fire a mail. Each of my developers gets hundreds of miles a day and only half needs his attention. For example, only if Priority changed to Urgent or Red Alert send the notification,, if it was changed to medium or high don't send it.

Therefore, I want to control on which fields that are being edited will send a notification mail. is it make sense?

I tried to use ScriptRunner to send an email, but it sends a custom mail and not a "Notification mail" that highlights the changes that were made


author: Alex Koxaras _Relational_
body: [@Sharon Porat](/t5/user/viewprofilepage/user-id/5061904)

What I would do in your case then is:

* Create a bunch of different events based on whatever template you want (e.g. generic or issue created or whatever)
* Write a listener which will gets trigger on field changes
* Use the dispatchEvent() (com.atlassian.jira.event.issue.IssueEventManager) to trigger the event you want and sent out notifications based on the notification you will prepare.

Let me know if the above is clear.


author: Sharon Porat
body: Hi [@Alex Koxaras _Relational_](/t5/user/viewprofilepage/user-id/4150197) , sorry but I am not sure how should I use the dispatchEvent()? can you please elaborate on that?


Tags: server