Options for custom field
Asked by Kristian:

Hi, I need to have a custom field, single select box, where I get the options from a different system.   

I understand how to create a custom field and manually creating the different options.   

is it possible to get the list of options from another system via an API call?   

![2024-08-23_12-39-28.jpg](/t5/image/serverpage/image-id/343463i00A9D688660456C5/image-size/large?v=v2&px=999 "2024-08-23_12-39-28.jpg")


Answers:
author: Rudy Holtkamp
body: Hi [@Kristian](/t5/user/viewprofilepage/user-id/4667843) ,

If you are using a form in a JSM project, you can use data connections, take a look at: <https://support.atlassian.com/jira-service-management-cloud/docs/create-edit-test-or-delete-data-connections-for-forms/>

If you use (regular) Jira, then you need to create an automation rule, that gets the options and add them via the[rest api.](https://docs.atlassian.com/software/jira/docs/api/REST/1000.824.0/#api/2/field/{fieldKey}/option)

The hard part is the next time your run the automation, you need to only add/disable the differences of the two lists.

comments: author: Kristian
body: Thanks, this is for regular Jira Cloud  
I am looking into using ScriptRunner to call the REST api of the source application.   
As I understand it, in ScriptRunner you can call the REST api of Jira.   

So I am thinking that in the script I can call the REST api of the source to get the options I want to represent, and then call the Jira REST api to populate the custom field.   

And as you said, figure the logic when the data has changed in the source application   


author: Zulqarnain Ikram
body: I am not sure about ScriptRunner, but I did something similar a while ago using a middleware. Here's what I did:

1. **Get Request to the External System**: I made a GET request to the external system to retrieve the options.
2. **Import Data Using Azure Function**: I used an Azure Function written in Python to import the data in JSON format.
3. **Update Jira Cloud**: I made a PUT request to the Jira Cloud API to update the options.

The middleware can be run on a schedule or triggered by an event.

comments: author: Kristian
body: Do I understand it correct that this is what you did? ![2024-08-24_10-15-56.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/343625i6E338E1E00961419/image-size/large?v=v2&px=999 "2024-08-24_10-15-56.jpg")


author: Zulqarnain Ikram
body: Source App --\> Middleware in Azure --\> Jira API


author: Kristian
body: Ok, makes more sense to me :)   
I can try that route, either azure functions or AWS Lambda.


author: Marc - Devoteam
body: Hi [@Kristian](/t5/user/viewprofilepage/user-id/4667843)

No you can't you can get the items maybe by creating an automaton rule that executes a webrequest to get the options and then you will need to create another webrequest to the JIra API store the options, then you will be able to use them in JIra.

But the options ned to be stored in Jira to be used.

comments: author: Kristian
body: Thanks for the reply. While researching more I found that I maybe should be able to do this with ScriptRunner.   
With that I should be able to call an external api and populate the options.   
I have not confirmed any of this. :)


author: Marc - Devoteam
body: Hi [@Kristian](/t5/user/viewprofilepage/user-id/4667843)

Does the source you are trying to reach have an API option, if not, then you can't go the way I suggested.

If the source has an API, check the API docs on how to get the information.

Jira API docs can be found here: [api.atlassian.com](http://api.atlassian.com)


Tags: cloud

jira-cloud