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

Jira REST API to update options in select list (single choice) custom field

shardern January 12, 2023

Jira Service Management does not have a field for group picking for their forms (not that we have found at least) and I want to make a custom tool to keep a regular single select list updated with all of our groups.

I have got the groups easily enough, but cannot figure out how to take the array and push it to the custom field.

There is one API call I haven't been able to try since it asks for a "Context ID" which is something that I can neither find nor get in another API call (it just says my custom field doesn't exist, which it does).

Has anyone had any experience trying to do what I'm doing? Take an array of strings and make it the list on a custom field in Jira.

Thanks in advance!

1 answer

0 votes
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 13, 2023

Hi @shardern --

To get the Context ID, you need to click on "context(s)" link for your field in the Custom Fields list:

Screen Shot 2023-01-13 at 12.04.51 AM.png

Then click on the Create, edit or delete contexts link:

Screen Shot 2023-01-13 at 12.05.31 AM.png

And finally, click on Edit context:

Screen Shot 2023-01-13 at 12.06.11 AM.png

The "Context ID" will be in the URL of this page as fieldConfigSchemeId, for example:

https://YOURSITE/secure/admin/ManageConfigurationScheme!default.jspa?atl_token=LONGSTRING&customFieldId=10058&fieldConfigSchemeId=10158

Alternately, if you know your customFieldId (there's many ways to find this) you can use this API call to see the context(s):

/rest/api/2/field/{fieldId}/context 

I hope this helps!

By the way, if you don't know what Contexts are... you can read up on them here: 

tl;dr: Multiple contexts are useful if you want to use the same custom field with different sets of options for different projects or issue types.

Like say for one project you want to have certain groups as options, and in another project, you want a different set of groups. Using two different contexts would allow you to use the same field (this is a Good Thingâ„¢ in Jira administration).

That's why you need to specify a Context ID when adding options. They want to know which set of options. When they are created, every custom field starts out with just 1 default context.

shardern January 13, 2023

Hi Darryl

 

Thanks for the response. We had looked in the URL, but just never thought that the context ID would be config scheme id. Have to say, thats really unintuitive on Atlassian's part.

My other problem with the api call to get the context id was that the response always returned 404 for some reason.

I'll see if I can make progress using the context ID now that I know what it is since that (i hope) was the only bit blocking me.

 

Thanks again!

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 13, 2023

OH! I forgot to mention, it's so annoying but the field ID has to be specified like so:

https://YOURSITE.atlassian.net/rest/api/2/field/customfield_10120/context 

Totally lame - {fieldId} totally sounds like it should be a number.

shardern January 13, 2023

That probably explains why it couldn't find the custom field I made. The one thing Atlassian really needs to work on is the API and its documentation.

That'll be really handy. Thanks again

Like • 2 people like this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Upcoming Jira Events