Forums

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

Returning Multi-select field value as a string in Scriptrunner for Cloud

Anthony Giordimaina April 2, 2025

Hello,

I'm working on a Scriptrunner Cloud Behavior that is meant to dynamically update the Summary field based on what the user is inputting on the Create Screen. This needs to be happening as a Behavior while the fields are being filled out on Create rather than updating the summary via automation after the ticket is created.

The summary is being generated from the values of four custom fields: 

  • Two Single-select fields
  • One Text field
  • One Multi-select field

For the single-select and text fields the information is being updated in the summary as expected. For Multi-select, however, it is being returned as [object Object]. I am currently using join(", ") to try and return the values joined as a string.

Here is my code:

//customfield IDs changed here for simplicity

const smry = getFieldById("summary")
const appli = getFieldById("customfield_1")
const bv = getFieldById("customfield_2")
//
const env = getFieldById("customfield_3")
// ^^ This is the multiselect field ^^
const rt = getFieldById("customfield_4")


const apval = appli.getValue().value
const bvval = bv.getValue().toString()
const envval = env.getValue().join(", ")
const rtval = rt.getValue().value

console.log(rt.getValue().value)


// For context, one of the fields is only conditionally appended to the summary based on its own value.
switch (rt.getValue().value){

case "Value 1":
smry.setValue(apval + " | " + bvval + " | " + envval)
break;

case "Value 2":
smry.setValue(apval + " | " + bvval + " | " + envval + " | " + rtval)
break;

case "Value 3":
smry.setValue(apval + " | " + bvval + " | " + envval + " | " + rtval)
break;
}

 Why is [object Object] returned for each value in the multi-select field and how can I retrieve the actual values instead?

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Jim Knepley - ReleaseTEAM
Atlassian Partner
April 2, 2025

Hi @Anthony Giordimaina 

I think you need to cast the multi-select field value as a List first, which ultimately extends Iterable:

def multiSelect = getFieldByName("multiSelect")
def values = multiSelect.value as List
def commaSeparated = values.join(",")

 

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events