I have multiple workflows and listeners send custom emails. Why do deactivated users continue to receive custom emails? How can I stop this? Is there a condition I should be checking for?
You can check whether a user is active or not by the isActive() method in the ApplicaitonUser class. If a user is inactive, you should not send a email.
I have put the following in the Condition and Configuration section of the Send a Custom Email Listener. Still emailing inactive users.
import com.atlassian.jira.component.ComponentAccessor
def locale = ComponentAccessor.getLocaleManager().getLocalefor(currentUser)
def approversCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Approvers")
def watchers = ComponentAccessor.getWatcherManager().getWatchers(issue,locale)
def validUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().isActive()
def recipientsTo = issue.getCustomFieldValue(approversCF)?.findAll {validUser}?.collect {it.emailAddress}?.join(";")
mail.setTo(recipientsTo)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.