Hello, I am using the Automation Rules in Jira Cloud, and trying to solve a "classic": "if issue with summary does not exist, create it".
I have made an automation down to the point where I have these following things available to me:
1) A list of linked issues: {{lookupIssues}}.
2) A {{summaryName}} variable.
I now would like to know how to go about checking if the linked issues list contains an EXACT MATCH of the {{summaryName}} variable.
Using the: "summary ~ "\"{{summaryName}}\"" does not provide an exact match, as I have other issues that might contain the summaryName, but also include more.
(E.g. TEST-7 has the summary: "Test Issue", TEST-8 has the summary: "Test Issue2")
I have already tried branching for each of the {{lookupIssues}}, and checking:
```
If: Compare two values
{{lookupIssue.summary}}
equals
{{summaryName}}
```
But I am unsure how to continue, because I need to exhaust the checking of the list, before I know if the summary is an exact match, and thus continue.
(I tried setting a variable value if a match was found, but seems like it isn't available after the branching scope? Or perhaps I am using it wrong)
P.S I am surprised that a text field (Summary) does not allow the '=' operator to check for exact matches.
Hi @Chris Rosendorf ,
Welcome to the community !!
Unfortunately at present jira does not support "=" for text search. There is already a feature request and you can vote and watch for the updates.
Thank you, I think this is a pretty core feature that's missing, and one that doesn't seem very difficult to actually implement...
Regardless, I've accepted that it doesn't exist, but just want to find a work-around that's available to me. I saw that a work-around is utilising ScriptRunner, can I do this in the Jira Cloud Automation environment, and if so, could you perhaps help me with it?
issueFunction in issueFieldExactMatch(subquery, fieldName, regularExpression)
issueFunction in issueFieldExactMatch("issue in linkedIssues({{triggerIssue.id}})", "summary","^{{summaryName}}$")
Would something like that work? And can I just write that, or do I need to be under a ScriptRunner tab, for it to work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Chris Rosendorf ,
You need to have the scriptrunner plugin installed in your jira.
Syntax:
issueFieldExactMatch (subquery, fieldname, regexp)
Example:
issueFunction in issueFieldExactMatch("project = ABCD", "summary", "Test")
Official documentation is in https://docs.adaptavist.com/sr4js/latest/features/jql-functions/included-jql-functions/match-functions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have ScriptRunner for Jira, I can see it in the "Apps" tab, "ScriptRunner Enhanced Search" and "ScriptRunner for Jira", as well as some other apps unrelated to this.
I can't seem to use the issueFunction in issueFieldExactMatch, though:
Perhaps you could give me a hint as to where to enable it? :)
Just to re-iterate, I am on Jira Cloud, given that, is it still possible?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chris - Welcome to the Atlassian Community!
What trigger are you using to kickoff the rule?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am using a:
When: Value changes for Description
To start the process, because that's when I need to check through and start the rule.
Does this impact the way I can search through the linked issues?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe try doing a Branch for Linked Issues (instead of lookupIssues), then under the branch this:
If: Compare two values
{{triggerIssue.summary}}
equals
{{issue.summary}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I need to ensure that NONE of the linked issues matches the summary, and I can't say that index 0 didn't match the summary, so create the issue, but then the 3rd index in the list is an exact match. Also it would create duplicates, if it loops through the linked issues and just checks that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you have issues A, B, C linked to Issue D. The description for issue D changes, issue A is a match on the summary but B and C do not. What are you wanting to happen?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For that example: Nothing.
When a {{summaryName}} is NOT an exact match for a summary of an issue in the list of linked issues (A, B, C) then create it - (The creation part I've already got working)
I just want to ensure I don't make duplicates of everything every time something is changed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share a screenshot of your rule?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's a bit too big to post a screenshot of, and I don't think that will provide much more value than the description I wrote.
Main thing is: "Create an issue with X summary, if summary with X does not exist".
I have a list of linked issues, so I know what to check through.
I have the summaryName in a variable, so I know what search term I am looking for.
All I need is the comparison of if {{summaryName}} is not an exact match for an issue's summary in the lookupIssues' list. Which is really hard to do, without an = operator.
So to recap what I then tried:
For: branch from linkedIssues
And I can now use a field comparison for "summary equals {{summaryName}}", but if I can't edit a variable, nor access a created variable outside of the branch scope, those also do not give me a way to check if the summary exists in the list by looping through it in a branch.
Perhaps you have a good idea to solve this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you have a very long rule to post, you can try a browser addon or separate app to capture the image with the page scrolling.
Back to your question...and without seeing your rule for context...
Rather than branching over the issues you could try:
{{lookupIssues.summary.match(varYourSearchExpression)}}
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.