How to populate a dropdown field's selection values from an external REST resource?

A few years ago, Andris Bērziņš answered a question about populating a dropdown field’s values with a REST request. His answer for how to solve this with a P2 plugin:

What I did was write a JIRA plugin that had a service which retrieved information from outside JIRA and stored it. Then I added REST functions to the same plugin that sent that data. Lastly, I created a custom field text box and added a javascript to its description that used ajax to get data from my REST function and populate the tree.

Even today, it’s a good summary of the solution. I wonder if anyone knows any open-source examples that demonstrate this approach? Or any examples that solve the problem any other way?

1 Like

I guess an alternative way to solve this is to simply proxy the request. That would save you the trouble of creating a service that caches the information. I would personally always be somewhat hesitant to create a dependency on an external resource from a P2 plugin as you don’t know if the customer instance has an active internet connection.

Good point, in general. I’m asking on behalf of a customer developer where the plugin would call a resource known to be available. So less a concern for my case.

1 Like

You can’t really proxy the request though since the value stored in the issue is based on the option id rather than the option value.

I’ve implemented something similar to this recently where the user was uploading a list of entries which were then synced into the options list when the options were requested - disabling/enabling/creating options as required.