Jira Cloud Scriptrunner Script Listener Condition

Nicholas Holleran November 29, 2022

I'm struggling to find the correct condition syntax to make my script listener run. I just want it to run based off a custom field but I can't figure out what the syntax should look like.  This is what the custom field looks like in a json if that helps.image.png

I want the condition to be whenever the value is 'IO-TOOLS'. Right now I have the condition as issue.customfield_11623.value == 'IO-TOOLS' but it throws the error 

2022-11-25 17:07:43.595 ERROR - The condition: issue.customfield_11623.value == 'IO-TOOLS' evaluated to: ["Evaluation failed: \"issue.customfield_11623.value\" - Unrecognized property of `issue.customfield_11623`: \"value\" ('value'). Available properties of type 'List' are: 'concat', 'every', 'filter', 'flatMap', 'flatten', 'includes', 'indexOf', 'join', 'length', 'map', 'reduce', 'slice', 'some', 'sort'"]

Any help would be appreciated! 

1 answer

1 accepted

2 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 29, 2022

It's the == that is the problem.  Customfield_11623 is probably a select type field of some sort, so when you use .value to get the contents, you are getting a list object, not a string, and you can't compare lists with strings.

You need to delve a bit deeper and open up the list.   I think you need .value.includes to unpack the list and compare what the objects in at with "io-tools"

Nicholas Holleran November 30, 2022

I changed the condition to issue.customfield_11623.includes('IO-TOOLS') and it seems to run that with no errors, but it never evaluates to true even when I try it with test tickets set to that value.

 

To help with my testing is there a way to print the payload on the condition each time it runs?

Nicholas Holleran December 5, 2022

Solved thanks! Solution was value inside the 0th index and I cant believe I hadn't tried that. For anyone else having this issue it looked like 

issue.customfield_11623[0].value == 'IO-TOOLS'

Like Kevin Paulovkin likes this

Suggest an answer

Log in or Sign up to answer