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.GroupMembershipCreatedEventimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.mail.Emailimport 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)
@Mike Rathwellwhat was the line you added to see which group was acted upon?
It looks like you're new here. Sign in or register to get started.