Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding options to a custom field by bulk

Omid Zolfaghari
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 26, 2022

Greetings Mates,

Can anyone help me to write a code to update options in a " Single Select" customer filed value ? I am absolutely new to Jira and scripting on it. I just could succeed to use my groovy now for running simple scripts as post functions.

Now I have a Single Select custom filed. It is a general custom filed being used by many issues.

I need to add some options on it and update the options sometimes.

I could find below question very similar to mine , but in the answer it is clear that options for an specific issue or issues will be updated by running the script.

In my case , I am going to update a custom field independent to the issues.

This is my code. I can call the custom filed by its ID (thanks to sample scripts). 

Now I need to update its options ...

It would be appreciated to have your advices and supports.....

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.fields.config.manager.FieldConfigManager

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def myCustomField1 = customFieldManager.getCustomFieldObject("customfield_10221")

?

?

?

Link of the similar question 

https://community.atlassian.com/t5/Jira-questions/script-of-add-values-to-single-select-list-custom-field/qaq-p/872349?tempId=eyJvaWRjX2NvbnNlbnRfbGFuZ3VhZ2VfdmVyc2lvbiI6IjIuMCIsIm9pZGNfY29uc2VudF9ncmFudGVkX2F0IjoxNjQ1ODkzMDkwNjU4fQ%3D%3D

 

Another one that I could find when writing this question :)

but without answer...

https://community.atlassian.com/t5/Jira-questions/Bulk-importing-adding-options-to-a-select-list-custom-field/qaq-p/181084

1 answer

0 votes
Mirek
Community Champion
February 27, 2022

Hi @Omid Zolfaghari

Welcome to the community and thank you for creating your first question :) ..

When looking at your problem I am wondering if you really need a script.. Definitively adding an option to Select List should be easy to do via UI..

And then.. Updating a value probably means that you have some conditions.. If condition is met you would update the field and choose this new value.. Is that correct?

Maybe we can simply use a standard Bulk Change.. Everything depends on the scale. You were saying "many issues" so I am wondering how many there are actually..

Could you please clarify a little bit more on effort that is required?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events