script field that would return Assignee's group?

hbhardwaj3 February 20, 2019

I tried the following script but didn't get the desired result.

Script :: 

import com.atlassian.jira.component.ComponentAccessor

return ComponentAccessor.getGroupManager().getGroupsForUser(issue.getAssignee())

 

Result ::

[com.atlassian.crowd.embedded.impl.ImmutableGroup@5ab0a9b9, com.atlassian.crowd.embedded.impl.ImmutableGroup@aa6f0adf, com.atlassian.crowd.embedded.impl.ImmutableGroup@1845f18a, com.atlassian.crowd.embedded.impl.ImmutableGroup@86a, com.atlassian.crowd.embedded.impl.ImmutableGroup@7403ff3, com.atlassian.crowd.embedded.impl.ImmutableGroup@e239b761, com.atlassian.crowd.embedded.impl.ImmutableGroup@42b66b45, com.atlassian.crowd.embedded.impl.ImmutableGroup@9099bd68, com.atlassian.crowd.embedded.impl.ImmutableGroup@852dcdc5, com.atlassian.crowd.embedded.impl.ImmutableGroup@976d6f29, com.atlassian.crowd.embedded.impl.ImmutableGroup@95a62d82, com.atlassian.crowd.embedded.impl.ImmutableGroup@ca5d9308, com.atlassian.crowd.embedded.impl.ImmutableGroup@58e3f5fa, com.atlassian.crowd.embedded.impl.ImmutableGroup@2d90ea2a]

1 answer

1 accepted

1 vote
Answer accepted
Ben Poulson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2019
import com.atlassian.jira.component.ComponentAccessor

def groupObjs = ComponentAccessor.getGroupManager().getGroupsForUser(issue.getAssignee())
String[] groupNames = new String[groupObjs.size()]
for (int i = 0; i<groupObjs.size(); i++)
{
groupNames[i] = groupObjs[i].name
}
return groupNames.toString()

Your solution was close, but you were returning the actual group object, not the name. You may need to do some reformatting in the above script, but it's the right data.

hbhardwaj3 February 21, 2019

Thank you so much Ben! you are awesome!

it is working for me. 

Like Ben Poulson likes this

Suggest an answer

Log in or Sign up to answer