Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

How to refresh custom field after options are updated

Engin Yorgancıoglu September 3, 2018 edited

Hello,

Using a ScriptRunner behaviour, I can update the options of a custom field programmatically, based on the value of another field . However there is one problem: I can only see the new options after I close and re-open the same screen (Create).

Is there a way to be able to see the new options right away?

It could also be about the way I update the options. Please see the code below. It clears all previous values and adds new options (fetched from an external web service).

def setCustomFieldOptions(fieldConfig, newItems) {
    // delete old list
    def optionsManager = ComponentAccessor.getOptionsManager();
    optionsManager.removeCustomFieldConfigOptions(fieldConfig);

// populate field options
def newSeqId = 0;
for (String item : newItems) {
optionsManager.createOption(fieldConfig, null, newSeqId++, item);
}
}

 

Thanks for any help.

Regards

2 answers

1 accepted

2 votes
Answer accepted
Krisztian Kovacs
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.
September 4, 2018 edited

hi there,

Unfortunately not, when you create new options the screen has to be reloaded. That's when Jira populates the form fields.

Why do you have to keep updating the custom field options? This overrides previous custom field data. I mean I'm sure you have a good reason, just wondering.

 

Engin Yorgancıoglu September 4, 2018

Hi Krisz,

Thank you for your response. Actually your initial suggestion worked for me, i.e:

form.SetFieldOptions(cfOptions);

The reason to keep updating the option is that these are actually managed in another system. New items may have been added or existing items may have been removed in that system and the custom field options need to be synched with that list.

This approach is indeed causing a problem: It is ok when creating a new issue, but later on, e.g. in the Edit screen, the assigned value does not match any item in the list since the options have been updated and all the option ids are now different (although the text may remain the same).

I will be looking into how to solve this issue, any suggestions you may have are most welcome.

0 votes
Engin Yorgancıoglu September 4, 2018 edited

Deleted - sorry, his post was meant to be a reply.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Upcoming Jira Events