Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud, our FedRAMP Moderate offering, is coming soon! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Upcoming Jira Events