Forums

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

Removing Values in One Variable That Exist in Another

Mafe Ortega
May 20, 2025

Hoping someone can help me with a Smart Values question.

I have two variables defined in my automation rule:

var X: "e5a9e2ce-3d34-47b2-bc03-078197c2a7cf", "c1466970-6196-4741-9425-237c3466b37d", "dc1603c3-6941-4003-a660-1f522f8d4b5f", "ee49ea67-3549-4733-a3d3-98b24c35f852"
var Y: "c1466970-6196-4741-9425-237c3466b37d", "ee49ea67-3549-4733-a3d3-98b24c35f852"


What I want to do is remove any values from var X that also exist in var Y.
Expected result:

var Z: "e5a9e2ce-3d34-47b2-bc03-078197c2a7cf", "dc1603c3-6941-4003-a660-1f522f8d4b5f"


Is there a way to do this using Smart Values in Jira automation or any other way to do it?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

5 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 Champions.
May 20, 2025

Hi @Mafe Ortega 

There are a couple of ways to do this; let's try the one using a regular expression and the replaceAll() function.  First the answer and then how it works:

  • action: create variable
    • name: varX
    • value: what you show above
  • action: create variable
    • name: varY
    • value: what you show above
  • action: create variable, to build a regular expression to remove the varY values
    • name: varRegEx
    • value: 
({{varY.remove("\"").split(", ").join("|")}})
  • action: something that needs the values removed from varX
{{varX.remove("\"").split(", ").replaceAll(varRegEx, "").match("(.++)").asJsonString}}

 

How that works...

  • Your variables contain double-quotation marks, and those must be removed to work with the later steps. We use the remove() function to do this, escaping the double-quotation mark for the removal.
  • We need a regular expression to remove those values.  After we cleanup varY, we split() it into a list and join() it with pipe characters to make an expression such as: (A|B|C)
  • Chaining those earlier operations, we now use replaceAll() which takes the regular expression and replacing any values found with an empty string
  • The result of the replacement could leave empty spaces in the list, such as: E, , F, G.  And thus we add a match() function with a regular expression to only return non-empty results.
  • Now we have the answer, although without the double-quotes. We can add those back with the asJsonString function; this could also be done with iteration.
  • The result is a list of values. Please join or iterate them as needed for {{varZ}}

 

The other way do do this is with a regular expression to directly remove the values (using negative lookahead). I have observed inconsistencies using this with rules, so I recommend sticking with replaceAll() rather than trying to do this with a single match() expression.

 

Kind regards,
Bill

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 Champions.
May 30, 2025

Hi @Mafe Ortega 

Just following up to check if this answered your question.  If so, please consider marking this one as "answered".  That will help others with a similar need find solutions faster.  If not, please let the community know what help you need with the rule changes.

Thanks!

Aleksi Leinonen
Contributor
June 17, 2026

Hi @Bill Sheboy , first of all, thanks for your work on the forums, you're the MVP,

What kind of inconsistencies have you observed?

I was just trying this out and found that Automation smart values DO support negative lookahead, at least in this case:

variableA (^(?!({{lookupIssues.customfield_12345.value.flatten.distinct.join("|")}})$).+$)

variableB: {{issue.customfield_12345.value.match(variableA)}}

This returns all values that the current issue has but the lookupIssues don't have. Useful when trying to remove only the values that don't overlap.

kh-federico
Moderator
June 18, 2026

Hi @Aleksi Leinonen 

This topic has been locked because the thread has become a bit dated. If you’d like to keep the conversation going or have additional questions, we encourage you to start a new topic. You can read more about necro posting (“raising threads from the dead”) in our Community Guidelines.

Thanks!

TAGS
AUG Leaders

Atlassian Community Events