Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,464,918
Community Members
 
Community Events
176
Community Groups

Jira Cloud Scriptrunner Script Listener Condition

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

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"

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?

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'

Suggest an answer

Log in or Sign up to answer