I would like to do check new customer accounts (when their first ticket is created) for a specific email group (i.e. find anyone with an email address from "@example.com") and add them to a specific group.
I have ScriptRunner installed, but I have searched all through their tutorials and examples and can't seem to find anything that would solve this problem. I think it would be as simple as putting a script in the create post function with the following logic:
if email address included "@example.com" then
set group = "distributors"
The part that I can't find is how to look at the email address of a customer/reporter.
Hi @Paul Mata ,
yes, custom script post-function on create transition should work, please try something like this:
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.user.ApplicationUser
String USER_GROUP_NAME = "distributors"
String USER_EMAIL_PATTERN = "@example.com"
GroupManager groupManager = ComponentAccessor.getGroupManager()
ApplicationUser reporter = issue.getReporter()
if (reporter.getEmailAddress().contains(USER_EMAIL_PATTERN)) {
Group group = groupManager.getGroup(USER_GROUP_NAME)
if (!groupManager.isUserInGroup(reporter, group)) {
groupManager.addUserToGroup(reporter, group)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.