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?
Community moderators have prevented the ability to post new answers.
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:
({{varY.remove("\"").split(", ").join("|")}})
{{varX.remove("\"").split(", ").replaceAll(varRegEx, "").match("(.++)").asJsonString}}
How that works...
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
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!
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 , 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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.