Hi,
So I need to get the groups that the logged in user belongs to and make these groups appear as options in a multi choice custom field.
below is the code that gets the groups :
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level
def logg = Logger.getLogger("")
logg.setLevel(Level.DEBUG)
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def groupManager = ComponentAccessor.groupManager
def group
def g_group
//def userManager = ComponentAccessor.userManager
//def userUtil = ComponentAccessor.userUtil
//
def groupsval = ComponentAccessor.groupManager.getGroupNamesForUser(user) as List
//return groupsval
for(int k=0; k<groupsval.size(); k++) {
group = groupsval.get(k)
// g_group = groupManager.getGroupObject(group)
return group
}
How can I do that in script runner ?
I tried to create a multi group picker scripted field with multi group picker searcher but it gives me empty result :
,,,,,,,,
Ok, there's not quite enough detail here for us to be able to help much. Not on the script, that's fine, but we need to know more about what you're trying to achieve and exactly how. There's no point in us writing up one solution if it doesn't apply because you are doing something different.
The crux of this is "what is the target field for?". Is it intended to display a list of groups the editor is in at the time of the create/edit/transition? Should it be a list of groups that the editor is going to select one or many of? Or something else?
thanks for the reply, so I have 2 postfunctions, one to add user/s to group/s and the other to remove and these postfunctions only the admin of the project can use.
I have a field for user picker and another field that is a multi choice and has the names of certain groups names depending on the project using that field ( I did that so no one from the project can manage any groups except what appears to the member of the project.
instead of creating a context of that multi choice field ( group ) to each project, I am trying to make it dynamic so that it shows only the groups the user belongs to.
(I will add later a condition where jira admin is excluded from the result but I need to make it work first)
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.