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