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:
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?
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(",")
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.