Linking newly created issues from an automation
Asked by Philip Witt:

Hi guys,

I have project A, B, and C. Im trying to create an automation rule in project A which creates an issue in project B and another issue in project C.![Automation 1.jpg](/t5/image/serverpage/image-id/348960iECB9380FBCC6B3AA/image-dimensions/397x421?v=v2 "Automation 1.jpg")

I also want to link the issues in all directions: A-B \& A-C \& B-C.

The links between A-B and A-C work by using "Choose fields to set..."![Automation 3.jpg](/t5/image/serverpage/image-id/348961i7B77C1F694F4452C/image-size/large?v=v2&px=999 "Automation 3.jpg")

The problem I'm facing is the link between the newly created issues in project B to C.

Is it possible to create these links? I believe I need to create a variable and use JSON, so I have already expanded my automation rule to this:

![Automation 2.jpg](/t5/image/serverpage/image-id/348966iE4FE7818A95C0C10/image-dimensions/363x505?v=v2 "Automation 2.jpg")![Automation 5.jpg](/t5/image/serverpage/image-id/348971i97246A8782938A61/image-size/large?v=v2&px=999 "Automation 5.jpg")![Automation 4.jpg](/t5/image/serverpage/image-id/348967i1BD8103A0F39C798/image-dimensions/430x373?v=v2 "Automation 4.jpg")

When I do this, I create a link between B to C. Yay! But the link between A and B won't work anymore :(

I believe I'm on the right track with the variable and JSON. Do I have to put JSON in the action "Create (2nd) issue" (I think I've tried it before but it didnt work either)? Does it have to be in a new action at the bottom in the action "edit fields"? Is something else missing? Is the structure off?

Any help is much appreciated! :)


Answers:
author: Bill Sheboy
body: Hi [@Philip Witt](/t5/user/viewprofilepage/user-id/5600069) -- Welcome to the Atlassian Community!

The structure of your *complete rule* will determine if this scenario is possible. To confirm this, please post an image of your complete rule in one single image for context. (This may be captured with an image capture tool or browser add-in for scrolling-page capture.)

Until we see that information...

The keys for a scenario like this are:

* saving the keys of the issues as they are created for later usage in issue linking, and
* using a multiple-project or global scope rule. *(Single-project scope rules may create issues in other projects, but cannot access or update them otherwise, and so the linking would not work. Instead the rule must be multiple-project or global in scope. Your Jira Site Admin will need to help for changing a rule's scope.)*

Kind regards,  
Bill

comments: author: Philip Witt
body: Hi Bill, thank you for your reponse! :)

Scope is something I havent thought about yet, right! However, since the creation of the issues and some of the links work, I dont think this is the main reason for the problems I am facing. However, I have the necessary Jira site admin permissions if needed.

I have two versions of the automation rule by now.

#1

The first automation rule has JSON as part of the second "And: create a new..." action.

![Automation 7.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/349179iC21C2C07E00EA2A5/image-size/large?v=v2&px=999 "Automation 7.jpg")

![Automation 9.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/349181i52822F7652783D8B/image-size/large?v=v2&px=999 "Automation 9.jpg")

--\> Triggering this automation rule will create the two issues succesfully. However, I am missing the link between project A and project B. The links between A and C as well as B and C are there.

#2

This automation rule has JSON in a separate action "And: edit issue fields".

![Automation 6.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/349180i202C96E3780A4B67/image-size/large?v=v2&px=999 "Automation 6.jpg")

![automation 8.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/349182i6387D33B218B8E7F/image-size/large?v=v2&px=999 "automation 8.jpg")

--\>Triggering this automation rule will create the issues successfully. Now, however, I am missing the link between B and C, which are the newly created issues.

Both automation rules share the same setup for the variable:

![Automation 5.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/349165i1C2CEFACA6B36BE6/image-size/large?v=v2&px=999 "Automation 5.jpg")

Unfortunately, I can find a way to create links in all directions: A-B \& A-C \& B-C. :(


author: Bill Sheboy
body: Thanks for that information, and I still believe this can be done in one rule (if the intent is to manually trigger it and create all the issues at once.

If you save the key after each issue is created, and then use branch on JQL, this will work. For example:

* trigger: manual
* if / else condition
  * *... conditions to decide if creating issue in project A*
  * action: create issue A
  * action: create variable to save {{createdIssue.key}}; let's name this one varKeyA
* else / if condition
  * *... more conditions, repeating the above pattern to save the keys*
* branch: on JQL to the project A issue with key = {{varKeyA}}
  * action: use either edit issue or link issues with the other issue keys to link them
* *repeat as needed for the other issues*

If you do not create all of the issues (A, B, and C) you could add additional conditions to check if the variables have a value before trying to link them.


Tags: cloud

jira-cloud