Forums

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

Question on Scriptrunner add-on

Manikandan K May 1, 2018

I have created new scripted field ( single user pickup) only from a single group.

But when i preview the field it shows "Anonymous" and it doesnt filter the users from the group and also in the screen user pickup option doesn't get pulled up. I have attached the screenshot for reference. 

 

Below is the script

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def groupManager = ComponentAccessor.getGroupManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def group = groupManager.getGroup("ITOPS - Devops Team")

 

 

2 answers

1 accepted

1 vote
Answer accepted
Ivan Tovbin
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.
May 1, 2018

Check the searcher for this field and make sure it is set to 'User Picker & Group Searcher'. Go to Administration -> Issues -> Custom Fields, find your field, click on the "Cog" icon to the right and select 'Edit' in the popped up menu.

However if I understood what you are trying to achieve correcly, then It won't work. You want to create a User Picker field, and you want to resctrict its select options to the users of a certain group only, yes? Well, unfortunately it doesn't work that way. Scripted fields are read-only, and code behind them should return a certain value which will be displayed in the field.

Manikandan K May 1, 2018

Please let me know how can we achieve this functionality. Can we add the script in post function to filter the users ?

Ivan Tovbin
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.
May 1, 2018

You don't need scripting to do it. If your Jira version is 6.2 or later then user filtering for single select user pickers is part of standard funtionality.  All you need to do is create a User-Picker (single choice) custom field and then set which groups it will be limited to in its configuration. More details in this documentation.

Manikandan K May 1, 2018

@Ivan Tovbin- Thanks it worked!

0 votes
Manikandan K May 1, 2018

image.pngimage.png

Suggest an answer

Log in or Sign up to answer