Add values to select list via automation

David Loszewski April 6, 2022

I'm trying to find a way to add values to a single select list via automation or workflow.   Is there any way to currently do this?   I've searched but unable to find a solution so far.   I found the following which matches my use case but am not sure how to implement: https://stackoverflow.com/questions/22892537/how-to-add-new-values-to-select-list-field-in-jira-dynamically-or-using-plug-in/23198416#23198416

 

2 answers

2 votes
Samuel Bartolome April 8, 2022

Hi @David Loszewski ,

Using automation or workflow post-function are easy ways to accomplish what you are looking for.

Are the values predefined (always the same) or do they come from a different field?

https://confluence.atlassian.com/automation/advanced-field-editing-993924663.html would give you a hint on how to update a field with automation. 

You can set the updated field with a permanent field, iterate an if-else based in some values so the field is updated based on another or copy value from another field.

 

The native post-function is a bit restricted on updating fields, so it will depend on which plugins you may have

David Loszewski April 8, 2022

@Samuel Bartolome I think your response assumes that I already have the values in the field.  I may not have been clear.  I'm trying to add an option/value to a single select list which, typically this is done manually through Issues -> Custom Fields -> <Field in question> -> Contexts and Default Values

I'm trying to accomplish the same thing through automation and/or addon script.   

The following is my use case: 

1. Single Select List Custom Field: Customers 

2. Text Field: New Customer

When a person enters a form with a value in New Customers, I want that value to be added as a list option on Customers.  

Samuel Bartolome April 8, 2022

Not sure you can achieve that  with automations, but probably you can do it with Scriptrunner as a listener maybe. 

In Scriptrunner there is already a build-in option (on-prem) to update values of fields in bulk, so  with that and the listener (if available in Cloud), it may do the trick

Tina Xu November 22, 2022

jira cloud -> automation -> action -> Send web request

Request URL:  https://yoursite.atlassian.net/rest/api/3/field/customfieldID/context/contextID/option

Headers:

Authorization: ******

Accept: application/json

 

method: Post

web request body: Custom data

Custom data:

 

{
"options": [
{
"disabled": false,
"value": "new option value"
}
]
}

 

please refer to this link: https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

Like Jawann Swislow likes this
1 vote
Tina Xu November 24, 2022

jira cloud -> automation -> action -> Send web request

Request URL:  https://yoursite.atlassian.net/rest/api/3/field/customfieldID/context/contextID/option

Headers:

Authorization: ******

Accept: application/json

 Method: Post

web request body: Custom data

Custom data:

 

{
"options": [
{
"disabled": false,
"value": "new option value"
}
]
}

 

please refer to below links: 

Send web request with Automation: https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

JIRA Rest API:https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-options/#api-rest-api-3-customfieldoption-id-get

 

 

Jawann Swislow January 18, 2024

This is the way.

Suggest an answer

Log in or Sign up to answer