Greetings,
My first post here: I have some external data (in a JSON format from a REST API endpoint) that I need to input into a multi select list (custom field) that is in Jira - the reason being I'd to do this via a script (ScriptRunner/Groovy or Java) is that the data changes frequently and there is a large volume of options, which makes manual maintenance of the custom field options very tedious and wasteful of time. I wanted to inquire if anyone else has had this challenge and how you've tackled it. There are two possible ways I can think of...
1) Write a "sync" script which runs on a regular basis that parses the endpoint JSON response and adds only new, unique options into the custom field via REST.
2) Although I haven't verified, would be to set options via a behavior (ScriptRunner) for the custom field, I've searched around and found code similar to below that has curated only specific options based on the definition found below - has anyone fed a REST API response into the options (rather than literally specifying each option below)?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
def optionsManager = ComponentAccessor.getComponent(OptionsManager)
def admin_field = getFieldByName("Administrator Access?")
admin_field.setAllowInlineEdit(false)
def admincustomField = customFieldManager.getCustomFieldObject(admin_field.getFieldId())
def adminconfig = admincustomField.getRelevantConfig(getIssueContext())
def adminOptionsOriginal = optionsManager.getOptions(adminconfig)
//define preferred options here
def admin_field_curated_options = adminOptionsOriginal.findAll {it.value in ['Yes', 'No']}
admin_field.setFieldOptions(admin_field_curated_options)