Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Check if value is in list

Jacob
Contributor
August 29, 2023

Hi,

I am having trouble getting my head around how to get this automated.

I want to check if the last comment email is in a custom field list.

I can get the last comment email and I can get the custom field list emails. 

I just can't get it to iterate through the list and say yes, it is in the list.

Hope it makes sense.

1 answer

1 accepted

0 votes
Answer accepted
Bill Sheboy
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.
August 30, 2023

Hi @Jacob 

Where are you trying to perform this test: in an automation rule, somewhere else?

If in an automation rule, you could probably do this test with either an advanced compare condition or with a regular expression and a match() function.

Kind regards,
Bill

Jacob
Contributor
August 31, 2023

Hi @Bill Sheboy 

Yes, it is part of an automation rule.

Tried using the advanced compare condition which works if there is only one email in the field. My issue is when there are multiple emails.

Tried the following:

In my custom field I have 2 users assigned.

One of them are the last commenter.

When running below command I just get false false but should be false true 

{{#issue.customfield_10027}}{{emailAddress.equalsIgnoreCase(issue.comments.last.author.emailAddress)}} {{/}}

Any help?

Jacob
Contributor
August 31, 2023

Also tried the match function which returns nothing 

{{issue.customfield_10027.emailAddress.match(".*(issue.comments.last.author.emailAddress).*")}}
Bill Sheboy
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.
September 7, 2023

Once you are inside of an iterator, it can only "see" that scope (and lower).  Thus the issue is no longer visible in the example from your earlier post.

Your custom field is a list of zero-to-many values, and so using match() alone may not work.  Let's try merging the values into a single text string first and then search:

{{issue.customfield_10027.emailAddress.join(",").match(".*(issue.comments.last.author.emailAddress).*")}}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events