Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get group name from a group picker field

Amir Katz (Outseer)
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.
June 25, 2018

I have a custom field which is a radio button, its values are group names (say G-1, G-2). These groups are defined in the server.

Code below omits the imports for bervity

def groupManager = ComponentAccessor.groupManager
def customFieldManager = ComponentAccessor.customFieldManager
def groupNameField = customFieldManager.getCustomFieldObjectByName("zzGroupPicker")
def groupNameSelected = issue.getCustomFieldValue(groupNameField) as List
def gn = groupNameSelected[0].toString()
def group = groupManager.getGroup(gn)

def msgDebug = "gn='" + gn + "', group=" + group
msgDebug

When I run it in ScriptRunner script console, the output is this:

gn='com.atlassian.crowd.embedded.impl.ImmutableGroup@7056c6db', group=null

So how do I get the group name (G-1) instead of what seems to be the object name?

Thanks

 

2 answers

1 accepted

1 vote
Answer accepted
Alexey Matveev
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.
June 25, 2018

Hello,

It would be

gn.getName()

Amir Katz (Outseer)
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.
June 25, 2018

Thanks!

0 votes
Salim Hammar
Contributor
January 24, 2022

Hi @Amir Katz (Outseer) 

 

I would like to do like you but for 2 fields , follow this link for undestand what i want 

https://community.atlassian.com/t5/Jira-Service-Management/Create-2-fields-dropdown-who-get-a-groups-crowd/td-p/1914816#M2615

I need help 

Amir Katz (Outseer)
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.
January 24, 2022

We've moved to the cloud, so most of the ScriptRunner stuff is n/a there.

Regarding your need, I have a slightly different requirement (get data dynamically from another source), so I'm looking into the cloud add-on 'External Data for Jira Fields'. It seems that it can provide what you need.

https://marketplace.atlassian.com/apps/1219994/external-data-for-jira-fields?hosting=cloud&tab=support

Salim Hammar
Contributor
January 24, 2022

Okay Thanks , but you don't have a idea for do the script because im new administrator in jira and i learn a java (groovy) . And i find the solution but i don't fin a solution or script worked than i can modify. for have what i want.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events