Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Send an email to user added to a specific group

Bertrand Delaitre September 26, 2022

Hi,

 

We want to send a "Welcome" email when user get access to jira (ie added to specific group).

We don't have specific plugin yet but using something like ScriptRunner is an option.

 

Can someone give me a solution on how to do that?

2 answers

1 accepted

1 vote
Answer accepted
Bertrand Delaitre September 28, 2022

I finally got a solution with your help.

 

Running ScriptRunner Listener "Send a custom email (non-issue events)" on event "GroupMembershipCreatedEvent" with this script in the Condition and Configuration parameter

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager

def userManager = ComponentAccessor.getUserManager() as UserManager
def user = userManager.getUserByName(event.getEntityName())
mail.setTo(user.emailAddress)

def result = false
if(event.getGroupName() == "jira-users") {
result = true
}

return result
0 votes
Florian Bonniec
Community Champion
September 27, 2022

Hi @Bertrand Delaitre 

 

You can create a Listener "Send a custom email (non-issue events)"

Apply to Global

Events: GroupMembershipCreatedEvent

Condition and Configuration:

result = false

if(event.getGroupName() == "YOURGROUPNAME"){

result = true

}

return result

 Then you can configure the template of the object and body.

You can access some information such the username of the user using $event.getEntityName() in the template.

Regards

Bertrand Delaitre September 28, 2022

Thanks. I've just installed a trial version of scriptrunner but using the listener you mention, I can't find how to specify the "current" user as the recepient of the email.

Reece Lander _ScriptRunner - The Adaptavist Group_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 28, 2022

You can configure the To: address dynamically by supplying a script in the Condition and Configuration parameter

E.g to send an email to the current logged in user you would do something like this:

 

mail.to = currentUser?.emailAddress

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.13
TAGS
AUG Leaders

Atlassian Community Events