Forums

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

How can I compare two smart value arrays and return all the matched values in Jira Automation?

Ralph Gerald Varon June 10, 2025

Hi everyone,

I'm trying to compare two arrays in Jira Automation and return only the matching values between them.

For example:

  • {{GraphQLNames}} = ["D&I eBusiness", "Jira Administrators"]

  • {{TeamMembershipNames}} = ["test", "Jira Administrators"]

 

Since smart values don't support functions like intersect(), I'm wondering:

  • Is there a way to return only the matched items using smart value logic?

  • Can this be done with Advanced Branching, contains(), and maybe match()?

  • Is it possible to create a new list or variaScreenshot 2025-06-10 175444.pngble that contains only the common elements?

 

Additional Context:

The two arrays come from different sources:

  • GraphQLNames is extracted from a GraphQL response listing the teams a user is a member of.

  • TeamMembershipNames comes from a Look-up Table that defines which teams are officially recognized/accepted for a specific automation.

Since users can belong to multiple teams — or even create their own — we need to ensure that only team names from the accepted list trigger the automation. So the goal is to check if there's any overlap between the user's teams and the approved team list.

Any suggestions or examples are greatly appreciated. Thanks in advance!

Thanks in advance 😊

2 answers

1 accepted

0 votes
Answer accepted
arielei
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.
June 10, 2025

Hey @Ralph Gerald Varon 

Run For-Each  - Advanced Branch loop on the main array and then compare the second array contains the smart-value.

 

if you are not sure which array to use, run it a second time for the second array.

 

Ralph Gerald Varon June 10, 2025

Hello @arielei

I've been trying to do that I'm not sure If I'm doing it properly.

Screenshot 2025-06-11 122922.png

arielei
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.
June 10, 2025

hey @Ralph Gerald Varon 

see images:
Screenshot 2025-06-11 at 8.54.53.pngScreenshot 2025-06-11 at 8.55.01.pngScreenshot 2025-06-11 at 8.55.20.png

Ralph Gerald Varon June 10, 2025

Greetings @arielei I Appreciate your help, thank you so much!

Ralph Gerald Varon June 10, 2025

I tried it out it worked when the matched value is like only one.

But if there are multiple matches it no longer returns anything.

Because I also like it to return when there are multiple matchesIt works.png

not work if multiple.png

0 votes
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.
June 10, 2025

Hi @Ralph Gerald Varon -- Welcome to the Atlassian Community!

There are several ways to solve this need, and the specifics of your scenario will determine how to proceed.

When you just need the common values, I recommend using the match() function with a dynamic regular expression.  For example...

  • Given two lists of values, such as fields: listOne, listTwo
  • create a dynamic regular expression for the first one to find matches
    • create variable
      • variable name: varRegEx
      • smart value: ({{listOne.join("|")}})
  • search in listTwo for common values:
    • {{listTwo.match(varRegEx)}}

 

The specific content of the fields impacts this approach.  That is, if there are reserved tokens or characters, they will need to be escaped in the "listOne" before the dynamic regular expression is created.

 

Kind regards,
Bill

Ralph Gerald Varon June 10, 2025

Hi @Bill Sheboy , Thanks for the warm welcome, I'm indeed new here. 

I'm not sure if I'm doing this correctly but I did what you said that I created a

  • Variable varRegEx - ({{listOne.join("|")}}) with my listOne as "GraphQLNames" then I print that out.
  • Aswell as the {{listTwo.match(varRegEx)}} with my listTwo as "TeamMembershipNames" 

but returns nothing tho.Screenshot 2025-06-11 120431.png

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.
June 11, 2025

The problem is you created two variables for listOne and listTwo, but created variables are always text type.  Please note in my first post the assumption:

Given two lists of values, such as fields: listOne, listTwo

 

With variables, they must be split() back into lists to work.  I bolded the differences:

  • create a dynamic regular expression for the first one to find matches
    • create variable
      • variable name: varRegEx
      • smart value: ({{listOne.split(", ").join("|")}})
  • search in listTwo for common values:
    • {{listTwo.split(", ").match(varRegEx)}}

 

Also a suggestion: for community questions, please do not accept things as "answered" unless they actually answer the question.  This will confuse people reading the threads in the future.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events