Scripted fields non display user groups

Max October 5, 2023

I have configured a script field in Jira that gets the list of groups from the reporter in an issue and displays the name of the unit depending on the group. But the group names are not displayed if I change Template from Group Picker to Custom or Text-Field.


If template custom or text-line is set, the result is [com.atlassian.crowd.embedded.impl.ImmutableGroup@7d085d23]

Is there any way to convert these to actual group names?

Next, a check will be set to see if the user has a specific group and the text will be displayed depending on that.

import com.atlassian.jira.component.ComponentAccessor

def userGroups = ComponentAccessor.groupManager.getGroupsForUser(issue.reporter)


if(userGroups.contains("Group")){
return "Developer"
}

 

2 answers

1 accepted

0 votes
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 5, 2023

Sure, just use the "getName()" method on the group objects.

Or in shorthand:

import com.atlassian.jira.component.ComponentAccessor
def userGroups = ComponentAccessor.groupManager.getGroupsForUser(issue.reporter)
if(userGroups*.name.contains("Group")){
return "Developer"
}
0 votes
Max October 6, 2023

@Peter-Dave Sheehan

Thank you very much.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events