Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ScriptRunner - How to grab the ID of an option

Hello Community,

I am trying to figure out how to grab the ID of an option from a select list.

I am able to grab the textual value from the field but now I want to map out what is the ID for that specific textual value.

Below is my current code that allows me to grab the textual value:

// Get the issue
/*MutableIssue currentIssue = getIssueContext() as MutableIssue

//Get the custcom Field
def custom_field = customFieldManager.getCustomFieldObjectByName("Country Priority");

// Get the Config for the field
def fieldConfig = custom_field.getRelevantConfig(currentIssue)

// Find the option to set, grab the value in country priority
def value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == "Priority 1"}

In the above code I grab the customfield, grab the options and filter out on the specific one I want. This for somereason returns me "Priority 1". What I need it to return is the ID/Value of Priorty 1, which happens to be 11322.

Does anyone know who I can fetch that value?

Thank you!


2 answers

1 accepted

4 votes
Answer accepted

Try this:

ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find{ it.getValue() == "Priority 1"}.getOptionId()

@Ivan Tovbin

This worked perfectly!

Thank you!


How to get OptionId for child in cascading dropdown

2 votes
Danyal Iqbal Community Leader Feb 21, 2018

If you want to get the optionID of the option that is already set in the CustomField you can use:


Get the class and use to get ID



If you want to set the customfield, use

def value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == "Priority 1"}

issue.setCustomFieldValue(cf, value)

Why do you need the ID?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

New cloud apps roundup - June 2021

Since our last roundup in April, Atlassian's Marketplace Partners have added over 100 new cloud apps to the Atlassian Marketplace to help your teams work more efficiently. Let’s take a quick look a...

370 views 5 11
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you