I am trying to create a script listener that sends an email notification when ever a group has users added or deleted. This looks like its possible using the 'GroupMembershipCreatedEvent' but i am wondering whether i could include the user ID of any user added/deleted on the email notification that's fired? Does anyone think that this is possible?
Hi Stephen,
If you want to send mail from an event not related to an issue, such as when a user is added, you can use a Custom Listener configure to handle the appropriate event, and a script such as this:
import com.atlassian.crowd.event.group.GroupMembershipCreatedEvent
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.mail.Email
import com.atlassian.mail.queue.SingleMailQueueItem
def event = event as GroupMembershipCreatedEvent
def email = new Email("a.zuevich@ya.ru")
email.setSubject("Subject")
email.setBody("User ${event.entityName} has been added to ${event.groupName}")
// email.setMimeType("text/html") // for messages with an html body
SingleMailQueueItem item = new SingleMailQueueItem(email)
ComponentAccessor.getMailQueue().addItem(item)
@Aleksandr Zuevich this little snippet just got me out of a world of hurt from a rather paranoic group (merely added an if statement to check if their group was the one acted on)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.