Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script Listener to Monitor User Group

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?

1 answer

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.jira.component.ComponentAccessor
import com.atlassian.mail.Email
import com.atlassian.mail.queue.SingleMailQueueItem

def event = event as GroupMembershipCreatedEvent

def email = new Email("")
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)
Mike Rathwell Community Leader Jan 03, 2019

@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?

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you