Exclude the custom field values using "!=" not working

Lakshmi S
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.
October 21, 2024

Hi Team,


(issue.getAsString("Issue Type") == "Change Request" || issue.getAsString("Issue Type") =="Bug") && (issue.getAsString("customfield_10204") != "APAC Fulfillment Implementation" || "APAC Support" || "APAC System Automation Implementation")

 

When I try to exclude the custom field values (in the condition) to set the field in the workflow post function, the "!=" operator doesn't seem to work. Is anything making a mistake here?

1 answer

1 accepted

0 votes
Answer accepted
Salih Tuç
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.
October 21, 2024

The issue is in "OR" conditions in this block:

(issue.getAsString("customfield_10204") != "APAC Fulfillment Implementation" || "APAC Support" || "APAC System Automation Implementation")

 For each value, you need to add "not equal" part to the left side:

(issue.getAsString("customfield_10204") != "APAC Fulfillment Implementation" || issue.getAsString("customfield_10204") != "APAC Support" || issue.getAsString("customfield_10204") != "APAC System Automation Implementation")

 

By the way (I didn't try but it should work since it is a Groovy condition), you can simplify this part as:

 

issue.getAsString("customfield_10204") not in ["APAC Fulfillment Implementation", "APAC Support", "APAC System Automation Implementation"]
Lakshmi S
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.
October 22, 2024

HI @Salih Tuç ,

This is working as expected.

issue.getAsString("customfield_10204") not in ["APAC Fulfillment Implementation", "APAC Support", "APAC System Automation Implementation"]
Like Salih Tuç likes this

Suggest an answer

Log in or Sign up to answer