Script Runner


Our organization is relatively new to JIRA (less than 2 years old) and few months back we purchased ScriptRunner to further customize our setup.

We would like to create a "dropdown" field that would pull static values from another "text" field. These fields are used on different screens.

I think we may have to include a filter with the below logic inside a script to load values for the dropdown field.
Custom Field 1 (existing) - Subsystem name (text)
Custom Field 2 (new) - Application (dropdown)

"Application" field available values =
"Subsystem name" field values (CONDITION -> project = "eRA Component Model" AND issuetype = Subsystem AND isactive = Yes)

How do I implement this? Please advice.


3 answers

Hi Venkat

You can get the project through the getIssueContext(), for example

def selectedProjectKey = getIssueContext().getProjectObject().getKey()
// or for the name
def selectedProjectName = getIssueContext().getProjectObject().getName()

regards, Thanos


Thanks a lot, Thanos. That worked. However, I couldnt get the behaviour to work on "Project" field change, I had to use another field, like "Issue Type", then the above script would work as desired.

BTW, the above solution is to make a text field a select field with JQL output that list ISsues from another project. Is there a way to list values of a particular field and only that field (no Issue key) as values of the select field? Does it have to be like a embedded SQL of some sort?


Thanks for your assistance.



Oh yes sorry forgot to mention that it should have been an initialiser script. For the second part of your question could you please give an example ?

No problem. Thanks.

For the second part of the question, from my above example, is it possible to not show the Issue key, but only display the summary field values?

Please see the attached image.

In the image, I dont want to see "ECM-2" in the dropdown.



Hi Venkat,

One way would be to create your own rest endpoint for it, and then call this one in your conversionList. Very similar to the documentation example Pick Issue from remote JIRA and having something like 

response.sections.each { section ->
	section.issues.each {

Let me try to see if there is a way via an ajaxOption (I have to check the src code)

regards, Thanos

Thanks Thanos. Let me take a look at your suggestions and get back to you.

Hi Thanos,

I tried the example you pointed me to and it doesn seem to pull any Issues (see the attachment). Can you please tell me what's missing?


import groovy.json.JsonBuilder
import groovy.transform.BaseScript


@BaseScript CustomEndpointDelegate delegate

pickRemoteIssue() { MultivaluedMap queryParams ->
//def query = queryParams.getFirst("query") as String

def jqlQuery = "project = RCDC"

def httpBuilder = new HTTPBuilder("")

def response = httpBuilder.request(Method.GET, ContentType.JSON) {
uri.path = "/rest/api/2/issue/picker"
uri.query = [currentJQL: jqlQuery]

response.failure = { resp, reader ->
log.warn("Failed to query JIRA API: " + reader.errorMessages)

response.sections.each { section ->
section.issues.each {
// delete the image tag, because the issue picker is hard-coded
// to prepend the current instance base URL.

return Response.ok(new JsonBuilder(response).toString()).build()


Forgot the attachment..

Hi Venkat,

I think you mean something like Select List Conversions ?

Thanks Thanos. 

I was able to use the sample - to setup a initilizer script to load JIRA Issues from another project into a text field as a select list.

However, I need to auto-select the value from the dropdown based on the out-of-box project selection. 

I am now using the below script on the "Project" field change behaviour. Can you please assist in the highlighted areas?


def selectedProject = getFieldById(getFieldChanged()).getValue()
def jqlSearchField = getFieldByName("Subsystem")

ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner-jira/latest/issue/picker",
query : true,

data : [
currentJql : "project = 'eRA Component Model' AND Summary ~ ${selectedProject} ORDER BY key ASC", 
formatResponse: "issue"
css : "max-width: 500px; width: 500px",


I have trouble using "Project" field in behaviours.


Thanks a lot in advance.


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

439 views 8 26
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you