Forums

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

Automation concepts -- Find Overlaps Between Lists

Estimated time to read: 3 minutes 

TL;DR: The current smart value list functions do not provide a way to find common items between two different lists. You may solve that using a dynamic regular expression with the match() function.

 

Why would you need this?

Let's assume you have two lists of work items with assignees from Lookup Work Items results, and you want to find common assignees. Perhaps these are people doing work on multiple teams and you need visibility when they have active work on both teams.

 

How to do it

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)}}

 

Some variations of the method

What if there are more than two lists? Hint: repeat the technique, progressively reducing the match results.

What if you wanted the all the values in one list which are not in the other list? There are several ways to do this, although one reliable method is: 

  • Again, with the same two lists...
  • Create the dynamic regular expression for the values you want to remove as a variable, named varRegEx. Again, let's assume that is from listOne.
  • We convert the "source" listTwo into text with join(); find the remainder using the replaceAll() function, which also takes a regular expression, replacing the result with an empty string; finally splitting back into a list; and cleaning up with another regular expression to remove any leftover, empty items
    • {{listTwo.join(",").replaceAll(varRegEx, "").split(",").match("(.++)")}}

 

Please note well: these methods assume the lists contain no special characters or regular expression tokens. When that happens, extra steps are needed to add escaping to the search expression.

 

I hope this article helps improve your automation "bag of tricks". Please let me know your feedback and how you might use this technique.

Happy rule writing!

 

1 comment

Tomislav Tobijas
Community Champion
June 16, 2025

Thanks for dropping this brilliance on us @Bill Sheboy !

I'm seriously thinking of opening a new folder in our KB called 'Tips from Bill' 😄

Like Bill Sheboy likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events