This topic describes how to create an e-mail notification rule.
To create an e-mail notification rule:
Enabling notification to the All filter for a certain bug or task is similar to using the "watch" mode in some systems -- i.e. a user will get email notifications whenever there is a change in the task status or any messages are added.
To get e-mail notifications both when a new task is added and when some other user (not him/herself) adds a message (bug-note), use the following filter:
|
Section |
Column |
Condition |
|
Message Settings |
Submitter |
is not Current user |
To get e-mail notifications only if the handler of the task, use the filter:
|
Section |
Column |
Condition |
|
Task Settings |
Handler |
is Current user |
To get e-mail notifications both when a high-priority task is added and when the John Smith adds some messages to the task:
|
Section |
Column |
Condition |
|
Task Settings |
Priority |
High |
|
Message Settings |
Submitter |
Customer |
To get e-mail notifications when other users add a message to the task for which the handler is the subscribed user:
|
Section |
Column |
Condition |
|
Task Settings |
Handler |
is Current user |
|
Message Settings |
Submitter |
is not Current user |
Use the e-mail notification rule based on the following script to send e-mail notification only when a handler has been changed. This script will return 1 when you change a handler adding a task or message -- 0 otherwise.
int ret = 0;
Collection messages = task.getMessages();
Collections.reverse(messages);
String oldHandler = task.getParent() != null ? task.getParent().getHandlerId() : "null";
if (messages.isEmpty() && !oldHandler.equals(task.getHandlerId()))
ret = 1;
for(Iterator it = messages.iterator(); it.hasNext();) {
String newHandler = it.next().getHandlerId();
if (newHandler == null) newHandler = "null";
if (!newHandler.equals(oldHandler)) {
ret = 1;
} else {
ret = 0;
}
oldHandler = newHandler;
}
return ret;Use the e-mail notification rule based on the following script to send an e-mail notification only when the user adds a message and not when the user modifies task properties. The following script will return 1 when the task has been modified by adding a message, or 0 when the task has been modified using Task->Edit.
int ret = 0;
Collection messages = task.getMessages();
java.sql.Timestamp taskDate = task.getUpdatedate();
for(Iterator it = messages.iterator(); it.hasNext();) {
java.sql.Timestamp date = it.next().getTime();
if (date.equals(taskDate)) {
ret=1;
break;
}
}
return ret;To get the time difference (in seconds) between two consecutive messages:
int ret = 0;
Collection messages = task.getMessages();
Collections.reverse(messages);
java.sql.Timestamp oldDate =
task.getSubmitdate();
long diff = 0;
for(Iterator it = messages.iterator();
it.hasNext();) {
java.sql.Timestamp newDate =
it.next().getTime();
diff = newDate.getTime() - oldDate.getTime();
oldDate = newDate;
}
return diff/1000;