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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Need to send notification when a project role is attributed/removed

I'm using ScriptRunner "Script Listeners" in order to send notifications whenever a user or a group have been attributed a role or removed from a projet role. 

I tried listening on these events "ProjectUpdatedEvent,RoleMembershipCreatedEvent, RoleUpdatedEvent, RoleMembershipDeletedEvent" BUT NONE HAS BEEN TRIGGERED SO FAR even though I have done the following : 

  • Added/Removed a user or groupe to projet role for certain projects
  • Added/Removed a user or group as default member to the projet role 

Any help on how to achieve what I want to do?

 

1 answer

1 accepted

1 vote
Answer accepted
Leo Community Leader Dec 17, 2019 • edited

Hi @Amine Filali,

I used "ProjectRoleUpdatedEvent", and it triggers mail to me whenever user added/removed in user and roles

used below script for sending test mails

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.mail.Email
import com.atlassian.mail.server.SMTPMailServer

def emailBody = "Hi Leo, \n\nUser role updated"
sendEmail("user@mail.com", "User role updated", emailBody)

def sendEmail(String emailAddr, String subject, String body) {
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()
if (mailServer) {
Email email = new Email(emailAddr)
email.setSubject(subject)
email.setBody(body)
mailServer.send(email)
log.warn("Mail sent")
} else {
log.warn("Please make sure that a valid mailServer is configured")
}
}

 Hope this gives you an idea

 

BR,

Leo

Suggest an answer

Log in or Sign up to answer
TAGS

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