Exclude Watchers From Custom Email Recipients
There are often cases where you want a listener to send a custom email to a group of people and the watcher/s of the issue to be member/s of this group. What will often happen (depends on your notification scheme) is that the watcher/s will get two emails for the same thing (one Jira notification email and one from the listener).
The script below makes use of the Condition and Configuration section to solve the problem.
import com.atlassian.jira.component.ComponentAccessor
def locale = ComponentAccessor.getLocaleManager().getLocaleFor(currentUser)
def watchers = ComponentAccessor.getWatcherManager().getWatchers(issue, locale)
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Multi User Picker CF")
//get the users' email addresses, in a comma separated string, that are members of the Multi User Picker custom field and are not watchers
def recipients = issue.getCustomFieldValue(cf)?.findAll { !watchers.contains(it) }?.collect {
it.emailAddress
}?.join(",")
mail.setTo(recipients)