Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Behaviour groovy - Hide values of a select list for a group



I'm a total groovy beginner !

As the title says, I need to hide values of a select list for a group.

This select list has a lot of values like 60-80 and I need to hide all values starting with CC* (around 20-30 values), need to hide these to everyone except a specific group 'DAF'.

I know Behaviour allows to except so I think the script should only hide all values CC*, then I add the exception group DAF.

I just have a draft with elements I gathered everywhere, could you please help me ?


import com.atlassian.jira.component.ComponentAccessor

//def courrier = getFieldById("customfield_10500")

def CC = 'CC$'
def issue = ComponentAccessor.getIssueManager().getIssueObject("NS-15") // get issue where field exist
def courrier = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Type de Courrier")
def optionsManager = ComponentAccessor.getOptionsManager()
def options = optionsManager.getOptions(courrier.getRelevantConfig(issue))
options.each {
//if (it.value == "CC1 - courrier 1" || it.value == "CC2 - courrier 2" || it.value == "CC3 - courrier 3"){
//if (it.value =~ 'CC$'){
if (it.value == CC){



Thanks !


2 answers


actually this script is not good enough, as it also shows all disabled elements of my list ... :(

Help anyone ?

Once again I finally found help within my team, this one script should do the job and be useful to others (beginners) :


//Script to hide some values starting with CC*, in a select list
//With Behaviour, just use an exception/allowance to restric usage to users/groups

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.customfields.option.Option

def mailCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("My mail select list field")
def mail = getFieldByName("My mail select list field") // Get the select list field
def optionsManager = ComponentAccessor.getOptionsManager()
def options = optionsManager.getOptions(mailCF.getRelevantConfig(issueContext))
def CCoptions = options.findAll { item -> !item.toString().startsWith("CC")} // Using the "!" character allows to do the opposite/contrary


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

189 views 1 6
Read article

Atlassian Community Events