Forums

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

Change/correct linking with Jira automation rules

Dave F
Contributor
May 5, 2022

I'm hoping for some help to get a project running smoothly.

We have a project set up for a very specific purpose and would like to do either/both of the following:

  • Remove any link used between certain issue types (e.g. issuetypes Bug and Spike should never be linked, regardless of the link type
  • Correct the link type if an invalid one for the project is used (e.g. Change a Blocks linked to a Relates to link)

As with linking in general, there may be multiple links between the issues at either end of the unwanted link. 

Are either of the above possible, and if so, how?

The more I read about filtering on links the more it seems Atlassian should notice years of complaints/questions and improve that bit of JQL, but in the mean time perhaps there's still a way with actions and branches in Jira automation.

 

I've just found out about the JQL option to search for issues based on a previously saved filter.

filter = "SavedFilterName"

Which it turns out you use to return a subset of multiple filters with AND.

filter = "SavedFilter AAA" AND filter = "SavedFilter ZZZ"

 When running automation against an issue identified as being of issuetype Spike I can then combine linkedissue IN and filter =

linkedIssue IN linkedIssues("{{issue.key}}") AND filter = "SavedFilter Bugs"

That's not removing the link or replacing it, but at least I can identify it with that. 

1 answer

1 accepted

2 votes
Answer accepted
Mark Segall
Community Champion
May 6, 2022

Hi @Dave F - You can accomplish link removals/adds with automation.  If you have the business logic, you could do something like this:

  • TRIGGER:  Issue linked.  When you add the trigger, it gives pretty solid documentation on what you can do:
    • Rule executes when an issue is linked to another issue. {{issue}} will always refer to the source issue, so if ISSUE-A is blocked by ISSUE-B, this rule will execute on ISSUE-B. To access ISSUE-A, use {{destinationIssue}}, and to access the link type, use {{linkType}} (e.g. {{linkType}}
  • CONDITION:  Your business logic that defines it is a bad link.  If you have multiple scenarios, you could use an IF/Else Condition
  • ACTIONS: Use Delete Issue Links to delete the bad links and Link Issues to create correct ones.
Dave F
Contributor
May 8, 2022

Does the Delete Issue Links action delete ALL links, or just one? We only want to remove the new, unwanted link (Bug/Spike), not any pre-existing links between valid issuetype combinations (e.g. Bug/Story or Spike/Risk).

How would I recreate the pre-existing good links if I have to delete all links, and wouldn't that mess with the history?

Good to know about the way the trigger views either end of the link. That will come in handy. Thanks

I'm pretty comfortable with the business logic to define a bad link, especially now I can compare to those saved filters and your explanation of the trigger

Dave F
Contributor
May 8, 2022

Actually, is there a defect with Delete Issue Links? The instructional text in it says "Please provide an issue or issue type to unlink", but I only have a multi-select dropdown of link types that will not accept free text or smart values.

It is not possible for me to provide what the instructional text requests.

Also, you can only select one of any To/From link type pair. Meaning to clear the link you want, you may need two Delete Issue Links consecutively to do the job.

Dave F
Contributor
May 8, 2022

Thanks goes to @Mark Segall for the additional information that got me to a solution I was after.

Some extra context for anyone else trying to do this:

  • When using the trigger "When issue linked" the Delete Issue Links action seems to only delete the link that triggered the automation. I'm not sure if that's always the case when used with other triggers. The wording on that action is not clear and doesn't accept issuetypes or keys as it suggests. I've logged a bug
  • In trying to match 2 issue types as invalid, the best way I found was to use an IF block, with multiple Related issues conditions. Each Related condition using JQL to check if both {{destinationIssue.key}} and {{issue.key}} matches some of the issuetypes in the 2 invalid sets. If the issues were only in one Related condition, the IF was False.
  •  Link issue, to correct/relink a valid issuetype pair with the wrong link type works from the {{issue}} end, so I created a link with the desired link type to {{destinationIssue.key}}
Like Mark Segall likes this

Suggest an answer

Log in or Sign up to answer