Can we add new values in select list from postfunction?

Any Idea!!!!!

2 answers

1 accepted

1 votes
Henning Tietgens Community Champion May 05, 2013

This should be possible through Script Runner also I didn't tried it by myself. You need the OptionsManager (as already mentioned by Chaithra)

OptionsManager optionsManager = ComponentAccessor.getOptionsManager()

and the createOption() method of this manager. You can get the fieldConfig for this method for the current issue and the customfield cf like this

def fieldConfig = cf.getRelevantConfig(issue)

If it's a single select list the parentOptionId is null. But you have to set a valid sequence and I think to get a valid sequence value you have to get all options for this fieldConfig (optionsManager.getOptions(fieldConfig)) and determine the next sequence number.

Henning

hi,

Yes you can do this by writing custom post function.

Refer com.atlassian.jira.issue.customfields.manager.OptionsManager for more details on creating options etc

I dont know about script runner, but we had done this in JIRA Service/ JOB Plugin. So this is doable in postfunction

Can it be done via script runner?

Any sample on how to implement?

please find the sample

Issue issue

CustomField customField

String value; //value to be added as option

Option opt = null;

FieldConfig relevantConfig = customField.getRelevantConfig(issue);

List<Option> options = optionsManager.findByOptionValue(value);

if(null != options){

for (Option option : options) {

FieldConfig fieldConfig = option.getRelatedCustomField();

if (relevantConfig != null && relevantConfig.equals(fieldConfig)) {

return option;

}

}

}

if(!value.equals(""))

opt = optionsManager.createOption(relevantConfig, null, (long) 0, value);

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,006 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot