It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Lookup group members using variable

Hi,

I need to lookup users in jira groups depending on value in a custom field "Site". I have tried to write the below function, which works if I write in the actual group name, shown below. What I need is an if statement (or similar) that sets a group name to the variable "group", which is then returned by the function.

Can this be achieved? Can similar behaviour be achieved with different technique?

Thanks

def lookupGroupMembers(String s){
/*
Parameter s = site
retVal = List of users
*/
def group = "None"
if ( s == "Site1" ){ group = "made-up-Jira-group"}

/* This works - using group name*/
def groupManager = ComponentAccessor.getGroupManager()
def retVal = groupManager.getUsersInGroup("made-up-jira-group")

/* This does not work - using group variable */
def groupManager = ComponentAccessor.getGroupManager()
def retVal = groupManager.getUsersInGroup("group")

return retVal
}

 

1 answer

1 accepted

0 votes
Answer accepted

You need to change line:

def retVal = groupManager.getUsersInGroup("group")

.. and use the variable instead..

def retVal = groupManager.getUsersInGroup(group)

 

Regards

Thanks! Worked like a charm :)

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you