Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

JAVA API - get all contexts of customfield

Nir Haimov Community Leader Feb 06, 2020

Hi,

We have few single select & multi select customfield with many contexts.

Each context for different projects, with different values to choose in the select drop down.

 

Can someone help me to find how can i get list of all contexts of a customfield?

And after getting the list, how to check for what are the options in each context?

 

Thanks,

Nir

3 answers

1 accepted

0 votes
Answer accepted

You can use FieldConfigSchemeManager and getConfigSchemeForField to get all the contexts

Then OptionsManager and getOptions to get the options in each of the Configs.

For example, in groovy:

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName('Severity')
ComponentAccessor.fieldConfigSchemeManager.getConfigSchemesForField(cf).each{
log.info ComponentAccessor.optionsManager.getOptions(it.oneAndOnlyConfig).collect{it.value}
}
Nir Haimov Community Leader Feb 09, 2020

Thank you @Peter-Dave Sheehan !

That's exactly what i needed :) 

0 votes

Hi @Nir Haimov 
On my side, I am able to get every allowed values using API.
For instance, by reaching this URL : https://xxx/jra/rest/api/latest/issue/createmeta?projectKeys=MyProject&issuetypeNames=Test&expand=projects.issuetypes.fields
I get this response :Capture.PNG
You may see the highlighted lines: there are the allowed values for the customfield_11110.

Hope it helps !

0 votes

For the Java API I would start at a page such as 

/secure/admin/ConfigureCustomField!default.jspa?customFieldId=14083

and check in actions.xml source file for the class that is behind that URL. Then in that class and the related jsp file, look for the Manager object that they iterate over to find each context

That lead me to the class ConfigureCustomField.java and the method getConfigs, which has schemeManager.getConfigSchemesForField(customField);

Suggest an answer

Log in or Sign up to answer
TAGS

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