Add value to select list custom field

MG January 30, 2022

 

Hi
I have a select list(single choice) custom field and a script that returns active sprint for a project, I want this active sprint in any time add to select list(single choice) custom field,

How do I do?

I don't know how add value to SelectListCF with groovy.

thanks

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Peter-Dave Sheehan
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.
January 31, 2022

This may not be 100% the best implementation for your use case given how few details you shared, but it is possible to add options to a SingleSelect field using a script.

You would use this API: OptionsManager.createOption

You could add an event listener that watches for "Sprint Created" and will add the newly created sprint to the correct field config. The challenge may be in detecting the correct project and field config to add the sprint to.

The other danger with this approach is that the list of options for your Select List will continually grow and eventually will cause performance problems.

The option suggestion by Fabio may be a better solution.

0 votes
Fabio Racobaldo _Herzum_
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 31, 2022

Hi @MG ,

you have a Select List custom field with some values and you want to add a value retrieved by a script dinamically.

You can't add a value dinamically to a Select List field. You should be able, through a script, to hide some values specified for the field but not add a new value dinamically.

In order to do that, in my experience, you need to create a text field custom field and, through a behaviour, transform it in a select list that aggregate values from your original select list and your script for active sprint.

Take a look to the following doc https://scriptrunner.adaptavist.com/latest/jira/behaviours-conversions.html

Hope this helps,

Fabio

TAGS
AUG Leaders

Atlassian Community Events