Forums

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

Hide/Show different radio button options

Raj
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 18, 2020

We have a custom radio button field called 'Account Type'. For most reques types, we want to display options A, B, C ,D and E, but for few request types,  we only want to show options A and E.

I have used below code but that did not work. Any help would be much appreciated.

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

def Actype = getFieldById("customfield_14562")

// Get access to the required custom field and options managers
def customField = customFieldManager.getCustomFieldObject(Actype.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)

def optionsMap = options.findAll {
it.value in ["A","E"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
Actype.setFieldOptions(optionsMap)

//--------------------------------------------------

0 answers

Suggest an answer

Log in or Sign up to answer