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
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Deleted - sorry, his post was meant to be a reply.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.