Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to build a drop down in Jira with values from another field?

April Smith
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!
April 7, 2021

Hello,

 

I am trying to use ScriptRunner plug in to dynamically build a select list based on comma delimited values entered by the user in another field

 

So field 1 is multi-line text field in JIRA which looks like this "red,green,blue,yellow"

 

and i'd like to write a script in scriptrunner that takes the values entered into that field and created a drop-down select with them. Is this possible? If so, is it still possible if the fields are in seperate projects?

2 answers

1 vote
Kate Kabir
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 11, 2021

Hi @Eric Smith 

Thank you for the question.

I can confirm that ScriptRunner for Jira Cloud does not currently have Behaviours like feature and this is something which we are considering at the moment as shown on the ticket In our public backlog located here.

Unfortunately, at this time there is no alternative that can be used to achieve your requirement of dynamically clearing field options or populating options on a screen as Atlassian does not provide the API's that would be required to be able to achieve these features and this means that these requirements are currently not possible inside of ScriptRunner for Jira Cloud.

I hope this information helps.

Kind Regards

Kate

0 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 9, 2021

Yes, that's possible using the Select List Conversion in scriptrunner behaviours.

On the initializer and your multiline text field, place a script that looks like this:

def csvFieldName = 'csv Field'
def targetSelectFieldName = 'field to convert to select'

def csvField = getFieldByName(csvFieldName)
def targetSelectField = getFieldByName(targetSelectFieldName)
def csvValue = csvField.value as String
targetSelectField.convertToShortText()
if(csvValue){
def optionMap = [:]
optionMap.put("","") // this is to have a blank option that allows clearing the field
csvValue.split(',').each{optionMap.put(it.trim(),it.trim())}
targetSelectField.convertToMultiSelect().setFieldOptions(optionMap)
} else {
targetSelectField.convertToShortText().setReadOnly(true).setDescription("Populate values in $csvFieldName before making a selection")
}
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 9, 2021

Oops, I didn't read carefully ... this assumes both fields are on the same issue.

If they are in different issue/project, you need to have a way to find the issue where the csv will be.

But the approach will be similar except for how you get the csvValue.

PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2021

I was clearly not paying very good attention ... I also didn't notice the "cloud" tag.

My response only applies to server/DC, unfortunately.

Suggest an answer

Log in or Sign up to answer