Script runner: setFieldOptions for custom picker field

Yin Liang March 25, 2024


I have applied some  custom picker fields (e.g. user picker for a specified group) with script runner. 

Is it possible to use setFieldOptions of  behaviour  to restrict the selections to a smaller scope ?

2 answers

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 25, 2024

Hi @Yin Liang

If you are using a Custom Picker field, setting the field options via Behaviour is not feasible as this is controlled by the configuration you have set for the Custom Picker.

Since you intend to create a custom field based on the User's Group, why not just use Behaviour to convert a Text Field to a List and pull the options from the REST Endpoint? You'll have more control and can filter the options accordingly from there.

I have given a similar solution in this Community Post some time back.

The sample provided in the Community Post is filtering the users by User Role. You will need to modify it to filter it by Group instead.

Thank you and Kind regards,


0 votes
Sean Chua _Adaptavist_ March 25, 2024

Hey @Yin Liang ,

Yes, that would be possible. There are some existing samples here which you can use as reference:

Hope it helps.


Yin Liang March 25, 2024

@Sean Chua _Adaptavist_ 


Thank you very much for your quick answer.


The filed to "setFieldOptions" is not system fields or  custom select field,  it's the "Custom Picker" filed created via script runner.

Pls see below code for the picker 


import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.canned.jira.fields.model.PickerOption

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.avatar.Avatar

def groupManager = ComponentAccessor.getGroupManager()
def userManager = ComponentAccessor.getUserManager()
def avatarService = ComponentAccessor.avatarService
def authenticationContext = ComponentAccessor.jiraAuthenticationContext

def group = groupManager.getGroup("team1")
def users = group.getMembers()

search = { String inputValue ->
return users

getItemFromId = {String id ->

toOption = { ApplicationUser user, Closure<String> highlight ->
def remoteUser = authenticationContext.getLoggedInUser()

new PickerOption(
value: user.key,
html: highlight(user.displayName, false),
icon: avatarService.getAvatarURL(remoteUser, user, Avatar.Size.SMALL)?.toString()


how to set options  for such field ? what's the input parameter for setFieldOptions()?

Sean Chua _Adaptavist_ March 25, 2024

Hey Yin Liang,

Thanks for the callout and I do apologise for reading the question wrongly - I must have been groggy from not having my morning coffee yet. It is as what you and ram has pointed out.

I would have gone with Ram's suggestion to use a Text field which is also feasible and he also shared his solution;

I have given a similar solution in this Community Post some time back.
The sample provided in the Community Post is filtering the users by User Role. You will need to modify it to filter it by Group instead.


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events