You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hi Community,
i need to add as watchers a specific group members with a postfunction while creating an issue.
Each user has a client group with all named the same way as its ended with '-clients' .
So i need a method that it fetch the group that name ended with '-clients' and add the members as watchers in the created issue.
The contains i've added below returns only a bloean value and i need to have the name of the group
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level
def currentAppUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().name
def groupManager = ComponentAccessor.getGroupManager()
def Keyword = "-administrators"
def searchgroup = groupManager.getGroupNamesForUser(currentAppUser).contains(Keyword)
//log.debug ("Test " + searchgroup)
//return searchgroup
if (searchgroup) {
def watcherManager = ComponentAccessor.getWatcherManager()
def userUtil = ComponentAccessor.userUtil
userUtil.getAllUsersInGroupNames([searchgroup]).each {user ->
watcherManager.startWatching(user, issue)
}
}
else {
log.debug ("The user is not a member of a client group" )
}
Thanks in advance.
Wajih
You are using the wrong method for the filtering as .contains() are designed to return a Boolean value. The following should give you a list of group name (type String).
def searchgroup = groupManager.getGroupNamesForUser(currentAppUser).findAll{
it.contains(Keyword)
}
I hope this helps!
Thanks a lot for the reply
yep i used find() method with regex to catch the group having that keyword on it then made a loop to catch all the group containing this keyword.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.