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 variable that contains only the common elements?
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 😊
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
see images:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 matches
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
but returns nothing tho.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.