How can I restrict group picker to certain groups? Edited

Hi there,

in JIRA, we like to implement a group picker (single choice) in order to define the responsible development group for a new feature out of a small list stored in the internal user directory.

Instead of defining validators for every workflow steps (at least 2 different workflows are affected) we thought about using global Behaviours (Scriptrunner add-on). After checking the documentation, I tried this validator script for the according customfield, mapped to all projects and issue types:

import com.atlassian.jira.component.ComponentAccessor

def respDevTeamFld = getFieldByName("Responsible Development Team")
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(respDevTeamFld.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionsToSelect = options.findAll { it.value in ["Option 1", "Option 2", "..."] }

Unfortunatelty, it does not work. The user picker for the customfield "Responsible Development Team" is not restricted to the defined values. The user is still able to select any group stored in the internal user directory.

Do you have any idea what is wrong?

1 answer

You are trying to set the field value , I believe you should set the field options instead.

Please refer the below . Replace the id's with actual group id's

Let me know how it goes . Add logging it will become easier to develop the required script

FormField resDevTeam = getFieldByName("Responsible Development Team") 
def ops = ["-1":"None"]
ops.put("10000","group 1")
ops.put("10001","group 2")

Hi Mizan,

just tried your suggestion, but unfortunately this doesn´t work (cannot see anything being affected)!

My script: 

import com.atlassian.jira.component.ComponentAccessor

FormField resDevTeam = getFieldByName("Responsible Development Team")
def ops = ["-1":"None"]

Script checker tells me that class "FormField" is unable to resolve...

Any ideas how to get this up&running? Many thanks in advance,

Maybe another idea/problem:

In the long run we want to select one or multi user groups based on a pre-defined list of existing user groups as we got some external partners working on our JIRA and we want to give them the possibility to browse and transition issues in certain cases.

AFAIK there is no option to show the user the entire list of possible options in a (multi) user group picker field itself (maybe the user doesn´t exactly know how the group is named), so i tried to manage this via a db driven field. Here i got the according list restricted to certain groups, but how to grant the according members of the choosen groups some permissions respectively use workflow conditions?

I could copy each time via event listener the db driven field to the user group field, but this sounds a bit creapy to me...

@Hans-Hermann Hunfeld:Where should I run this script?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,007 views 4 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you