I am using the ScriptRunner Behaviour Initialzer on a text filed and want to populate it with a list of components that users can pick from. I am using this as a look up since I don't have access to any server side tools to create the data set.
I am using this script but the Team field doesn't get populated. The API call is valid and returns data from my browser.
getFieldByName("Team").convertToMultiSelect([
ajaxOptions: [
url : getBaseUrl() + "/rest/api/latest/project/GA/components",
query: true, // keep going back to the sever for each keystroke
// this information is passed to the server with each keystroke
data: [
currentJql : "project = GA ORDER BY component ASC",
label : "Select the Team"
// specify maximum number of issues to display, defaults to 10
// max : 5,
],
formatResponse: "general"
],
css: "max-width: 500px; width: 500px",
])
Ok, this is tricky.
In order to use this convertToMultiSelect method you need to respect the output that their API is expecting and none available API have this by default;
The ideia is to use a Script Rest Endpoint that will return all components from a project with the expected output format:
https://gist.github.com/ItaloQualisoni/e663e7f6da3d3893fee37cb188d4cc28
You can test the rest endpoint by accessing the below url replacing the KEY with your project key.
http://JIRAURL/rest/scriptrunner/latest/custom/getComponent?projectKey=KEY
Having the Rest Endpoint working, you will have to update your Behaviour initializer to consume our new API , see below example:
https://gist.github.com/ItaloQualisoni/29bb890f018d83ecfcdb7bb3e3c7434c
I've tested these 2 scripts with JIRA 8.6 and it worked :)
The more I learn about ScriptRunner, the more impressed I am with what I can accomplish in JIRA. I am very happy you all are part of the JIRA ecosystem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.