Forums

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

Scriptrunner Jira Datacenter: how to hide the option in checkbox custom field

Saqib Dar
Contributor
December 10, 2022

Hi Community,

 Scriptrunner Jira Datacenter: how to hide the option in checkbox custom field

Thanks.

1 answer

1 accepted

4 votes
Answer accepted
Fabio Racobaldo _Herzum_
Community Champion
December 11, 2022

Hi @Saqib Dar ,

you can implement that through a behaviour (https://docs.adaptavist.com/sr4js/latest/features/behaviours).

A simple code could be the following :

def singleSelect = getFieldByName("YOUR_CUSTOM_FIELD_NAME_HERE")
def optionsManager = ComponentAccessor.getOptionsManager()

def cf = getFieldByName("FieldName")
def cfField = customFieldManager.getCustomFieldObject(cf.getFieldId())
def cfConfig = cfField.getRelevantConfig(getIssueContext())
def cfOptions = optionsManager.getOptions(cfConfig)
def cfA = cfOptions.findAll { it.value in ["A","B","C","D"] }.collectEntries { [ (it.optionId.toString()) : it.value ] }
cf.setFieldOptions(cfA)

Hope this helps,

Fabio

Saqib Dar
Contributor
December 11, 2022

@Fabio Racobaldo _Herzum_  thanks it works

Fabio Racobaldo _Herzum_
Community Champion
December 12, 2022

I'm happy for that

Like Saqib Dar likes this

Suggest an answer

Log in or Sign up to answer