Automate Issue Links on Automatically Created Issues

Christian January 23, 2024

Hello Everyone

I have a series of tasks that I have built an automation for that runs whenever a new epic is created. When an epic is created, a series of children stories and tasks that are the children of the stories created. I want to automatically create pre-determined links that certain tasks are blocked by other tasks, but I am unsure how to do so. 

Each issue created has an identifier field that allows me to know which other fields it should be linked with. 

the logic I am looking for is as follows

Task1 with field value A

Task 2 with field value B

Automation is run -> look at all children of the epic

If child of the epic has field value A > That issue will be linked to another issue that is the child of the epic with a different bust still specific field value issue with field value B 

I think I would be able to do this if I was able to run a double for loop. For loop 1 would loop through all children issues to find issue with Field Value A, for loop 2 would through all children issues until it finds that with Field Value B and links it to the issue with Field Value A. However, I do not believe I can create double for loops in Jira Automation. I am looking for other solutions to this. I am open to creative ideas.

Thank you all in advance 

 

 

2 answers

1 accepted

1 vote
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 Leaders.
January 23, 2024

Hi @Christian -- Welcome to the Atlassian Community!

You are correct: there are no nested branches for automation rules at this time.

Which is a good thing (at this time) because branches which could be on more than one thing are run in parallel and asynchronously, with no guarantee of when the branch will complete, up to the last step of the rule...and so your branches could collide.  There is a suggestion to add a "wait until done branching" option, but that will not help your scenario now.

 

There are probably a few ways to work-around the nesting issue; for your scenario you could try adding the issues and then linking in one rule:

  • trigger: on issue created
  • condition: to confirm issue type is epic
  • actions...add each child story for the epic with no branches to do so; that is, add them one by one
  • branch: on the created issues

Kind regards,
Bill

Christian January 26, 2024

Hello @Bill Sheboy, I was able to find a solution working with your help. I ended up running a loop for each of the Field value, with a lookup in the loop for the value to to link the issue to. I'm not sure it's the most efficient solution I could have come up with, but it works and I am happy with it.

Thank you so much for you help!

Christian 

Like Bill Sheboy likes this
0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 23, 2024

Hello @Christian 

Welcome to the Atlassian community.

I'm not sure if I understand your scenario. When you say issues with value A are to be linked to issues with value B, are you referring to a choice of value in just one field (ex. myField could be set to "A" or myField could be set to "B") or are you referring to separate fields (myField=A and yourField=B)?

Could you provide a concrete example of a set of issues with real/sample values in the fields and tell us how you would want those to end up linked together?

Is this a correct example?

Issue Key  myField value  Links to 
ABC-1  ABC-3, ABC-4 
ABC-2  ABC-3, ABC-4 
ABC-3  ABC-1, ABC-2
ABC-4  ABC-1, ABC-2
Christian January 24, 2024

Sorry, I'm having trouble explaining it. The myField value is a unique value and the only thing I now about each issue. I do not know the issue's Key. It is something more like this:

Issue Key               myField                Links to

?                             A                            myField = B

?                             B                            myField = C

?                             C                            myField = D

?                             D                            myField = A

My first thought was to use a JQL query to find the value to find the proper issue to link with, but the link issue action only allows me to link to trigger issue or most recently created issue. My other idea was to loop through issues until issue with until I find myField = A, then loop again until you find issue where myField = B, and do this for every link. However, I can't put in a double loop in Jira Automation. I'm at a loss now. Perhaps there is something that can be done with smart variables, but I'm not well versed enough to in that logic to be able to do it. 

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 24, 2024

In my example I filled in issue keys just to have a clear reference to indicate which issues would end up linked to which other issues, based on the value of myField.

I am going to defer to @Bill Sheboy on recommending possible solutions. He's really a rock star when it comes to Automation.

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 Leaders.
January 25, 2024

Hi @Christian and @Trudy Claspill 

The approach I outlined in my earlier post would work for this, finding the issues to link-to and then using the smart values as the key to add a single link per issue created.  For example: {{lookupIssues.first.key}}

The challenge is if you need to link to more than one issue to each one: that would require using a dynamic JSON edit expression rather than a single link added, due to the limitation preventing nested branching:  https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Linking-issues

The other work-around for multiple links is to use 2 rules: one to create the issues and another (triggered on issue created) to perform the linking.  That has a slightly higher risk of failure due to the possibility of all of the rules failing to trigger in a timely manner.

Tina Rusnak
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 15, 2024

@Bill Sheboy  - I have a scenario maybe you can help sorting out how to handle it as it is related to 1 issue type being linked to multiple other issues

In the same team board:

  • I have a form/issue type where people enroll to be placed in a talent pool
  • I have a form/issue type where people can post open roles

Is there a way to use automation so that whenever someone wants to enroll, when they  open the enroll form, they could see a list of all the open roles via links?

I am not a developer.  I'm not sure if the form would know of the links before the person actually submitted as it would be changing based on new open roles coming in and roles being closed out. I'm hoping folks can see the latest openings when they enroll so they can mark their interest in one or more openings.

Any ideas appreciated - thank you!

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 Leaders.
April 15, 2024

Hi @Tina Rusnak 

I do not have experience with Jira forms using dynamically populated data...although I suspect that capability may not be a built-in feature.

Please consider creating a new question for this one; that will ensure the maximum number of people see it to offer suggestions and potentially any possible addon apps to help.

Kind regards,
Bill

Like Tina Rusnak likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events