Hi ,
We are trying to populate a select list field with value's from external API
Our use case involves a select list field as follows -
When a user creates or updates a ticket, there will be a field name (e.g Primary application Name) which is a select list. If a user enters values that are available in the API endpoint, the field will populate or select an existing value from the API or list available from custom field and save it to the field. If the user edits the ticket, they will navigate to the field and update it with a value.
Users can either be searched using the UTR key or the Application Name associated with the UTR. Once selected those value’s will be saved to the field.
The external API use's a token which expires every 8 hours, however we can use the clientID and secret ID to generate the token. Please see below script which I tested but does not execute
Regards,
Bongani
may I ask a question on this scenario?
Where did you enter this code? Is it a Listener, a Behaviour or even a scripted field?
In the description this is not getting clear.
Actually, Listeners would handle the population of custom fields AFTER a certain event is triggered. This is very similar to Jira Automations and will update the field value based on what is entered in the custom field when the Listener runs.
Scripted fields will be showing some content when the issue is displayed. So they are more or less calculated at runtime.
Behaviours change the appearance of fields while an issue is edited. It can add values/content to a given field or hide options from select lists. This is all running in the client browser and needs JavaScript to work.
Unfortunately, it is not clear what is the intended option you would like to choose and in your sample script above, the only place you are referencing the custom field is in line 12 (when you define the name). After that, it is more or less only about handling the REST API, which I assume is working fine.
Please explain the use case a little further and where you added this code!
Hope this helps!
Thanks!
Stefan
Hi Stefan,
Currently testing this code using script console, Once I get the code to work I will use script custom picker in jira similar to the below example :
When a user creates a ticket, there will be a select list with value's populated from the external API to choose from, we are hoping to update the field option value in real time, where a user's search action dynamically pulls data from the API.
Regards,
Bongani
https://docs.adaptavist.com/sr4js/8.26.0/features/script-fields/built-in-script-fields/custom-picker
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
that means all that is important is the return value at the end. Can you check (and maybe log) the values that are returned?
Such as
log.error(searchOptions.toString())
return searchOptions
instead of
return searchOptions
Maybe this brings some light into this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Switch to Jira Cloud with Atlassian University! Explore new navigation, issue views, and Cloud features like team-managed projects and automation. Tailored for Data Center users & admins, these courses ensure a smooth transition. Start your journey today!
Enroll now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.