Select List (single choice) options from Json source

JF S
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 30, 2024

I'm trying to get the options for a Select List (single choice) field from a Json formatted file but I can't find any example.  The options may change daily so I can't rely on a static list.

The following one is similar, it's a Script Field, but the data comes from a REST API.

https://docs.adaptavist.com/sr4js/8.35.0/features/script-fields/built-in-script-fields/custom-picker

It works well as is, so I would like to know if we could plug a Json interface rather than using a REST API interface.

 

We are working with :

JIRA - 9.12.1
Adaptavist ScriptRunner for JIRA - 8.35.0

My skill level in JIRA/ScriptRunner/JAVA/Groovy is novice.

Thanks,
JF

1 answer

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 31, 2024

Hi,

Where your json file will be kept ? The REST API return a JSON, so in your case the file is somewhere on a drive? locally ?

I think the script field could be the solution, you just have to tell to your script where to look for the JSON.

JF S
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 31, 2024

Hi,

The example I was referring to is already in Script Field, I know I'm on the right path.  It's just that I can't find any information about these "search, toOption, PickerOption(), getItemFromId, renderItemViewHtml and renderItemTextOnlyValue".

The Json formatted file would reside under the Jira scripts folder.

/var/atlassian/application-data/jira/scripts/data/file.json
But it could be anywhere, what I'm looking for is the way to push the options found in this file in the Select List menu. 
Thanks,

Suggest an answer

Log in or Sign up to answer