Forums

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

How to retrieve the option id of the Select List (single choice) custom field

Eitan Gur
Contributor
May 22, 2016

I'm trying to conditionally update by post function a single choice select list.

When doing it by post function copy cf value from field to field - in certain cases it's being updated textually but in a two dimensional gadget for these values I can see that this issue is in "None" value.

Trying to do so by a scripted post function too - but I can't find the option_id's for its optional values.

I can see that this something like "cusomfield_xxxx-val" and then the text of the value.

 

Thanks

1 answer

1 accepted

4 votes
Answer accepted
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 22, 2016

You need to get and set an option object, not a string or id.

The snippet I used for fetching one should get you going:

def customFieldManager = ComponentManager.getInstance().getCustomFieldManager()

def cf = customFieldManager.getCustomFieldObjectByName("My colour list")

def fieldConfig = cf.getRelevantConfig(issue)

def value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == 'Red' }

 

 

Mamie Odette
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!
June 14, 2019

Hi,

What if the issue is on creation phase ?

I tried this method in init behaviour, for create issue, it didn't work

Thanks in advance,

Kieu_Le
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!
March 4, 2020

I have the same question also.
During issue creation, there is no "issue" object to pass into getRelevantConfig function. How do we get the fieldConfig without "issue" object?

def fieldConfig = cf.getRelevantConfig(??no issue object during create??)

thanks.

Suggest an answer

Log in or Sign up to answer