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

Groovy Logical OR

JiraYo
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2019

Hey guys, i am trying to evaluate whether a field "customer request type" is two values out of a possible 10. This is for sending an email using the JVME plugin under conditional execution.

On another site, the groovy OR command seems to be two pipes ( || ) but that does not seem to work:

return (issue.get("Customer Request Type").getName() == "General Cleaning" || "Event Cleaning")

That statement always returns TRUE, no matter the issue. Still returns true even if i put "fdsfdsf" instead of "general cleaning".

However the following does work correctly:

return (issue.get("Customer Request Type").getName() == "General Cleaning")

What is the correct way to evaluate the field and then return true if it meets "value 1" OR "value 2" but nothing else.

 

I looked through the groovy tutorial, but i am not a programmer... under logical operators it does appear that || is an or, but well i need help at this point.

 

1 answer

1 accepted

1 vote
Answer accepted
Alex Christensen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 21, 2019

I think you'll want something like this:

return (issue.get("Customer Request Type").getName() == "General Cleaning" || issue.get("Customer Request Type").getName() == "Event Cleaning")

When you just had the "|| "Event Cleaning", your condition was trying to resolve a string as a boolean value, which I believe just returns true because the string exists. 

JiraYo
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2019

works perfect thank you.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events