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?
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
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")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was clearly not paying very good attention ... I also didn't notice the "cloud" tag.
My response only applies to server/DC, unfortunately.
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.