Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hello,
I'm just starting to get into Jira Automation and I have a rule that creates a "Relates to" Link if another ticket is mentioned in a comment. While reviewing the audit log this morning I noticed that a pair of tickets were linked to each other twice. This is not an ideal behavior, so I was wondering if anyone could help me add some logic to prevent this.
Hello All,
I was finally able to figure it out. Here is my overall rule
The change was adding the 2nd comparison after learning more about smartvalues.
I'm sorry, but the proposed solution does not appear to fully address the outlined issue. There is still a possibility of adding a duplicate ticket from the opposing issue side.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Adding one more conditional before your Link action should do it.
I recommend the "Related Issues Condition" which allows you to test Linked Issues.
In the JQL, use this:
linkedIssue = {{comment.body.match ... }}
Below is a test rule I created to validate this approach:
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.
Do you get an error when you used your regex in the smart value for the "Matching JQL" field? That would surprise me -- I'd appreciate seeing that error.
My suggestion was to set the "Matching JQL" field for this new condition, for your situation, to be this:
linkedIssue = {{comment.body.match("([A-Z]+-\d+)")}}
My test rule doesn't use it, but I'm proposing the new conditional in your rule would.
This would prevent creating another link (of any link type) to the same issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank You @Mykenna Cepek - I misunderstood the validation message on that condition. I have added it and I'll see how it goes.
I really appreciate you helping me out
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Fred Deichler Hi there!
I want to express my appreciation for the idea introduced by @Mykenna Cepek ! However, during the implementation, I identified some additional issues causing "some errors" within the automation rule (shown in Rule's Audit log). One of the problems is that when a task key is mentioned in a comment as a smart link, it returns twice within smart-value
{{comment.body.match("([A-Z]+-\d+)")}}
..it is returned as (KEY-1, KEY-1). This is likely because it takes it from the label first and from the URL afterward..
Also, upon further a careful review of the returned JQL error:
((issue in linkedIssues("KEY-1")) AND (linkedissue = KEY-1, KEY-1)) AND (projectType in (software))
..I observed that "linkedissue" is used twice, which, in my opinion, is not quite correct. It was also preventing the addition of another linked issue if at least one (no matter which) is already linked. So I updated it to:
key in ({{comment.body.match("([A-Z]+-\d+)")}})
And it worked out perfectly! It now does not allow a duplicated linked issue to be added and prevents its addition from the opposite ticket (outwardissue or inwardissue).
Hope it helps.
Regards,
MD
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.
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.