Not able to link to multiple issues
Asked by David Yacubovich:

Hello All!

I am creating an automation that part of the flow will search for some stories based on criteria and then create one story in a different project that combine information from all the found stories. After that I would like to link the new story to all the stories that I created it from. So the linking part as what is not working. I am able to get the list of all the stories from the JQL an store in in the variable, but for some reason when I use Link Issue action, only the first story in the list get to be linked. I would appreciate any suggestions.

Thank you in advance!

![Untitled.png](https://community.atlassian.com/t5/image/serverpage/image-id/349094i63402ECB78DD67DD/image-size/large?v=v2&px=999 "Untitled.png")


Answers:
author: Trudy Claspill
body: Hello [@David Yacubovich](/t5/user/viewprofilepage/user-id/5600853)

Welcome to the Atlassian community.

Can you show us the entire rule, please?

Also, please show us the details for the creation of the varTarget variable.

And, please show us the output in the rule execution log for the execution of this rule.

comments: author: David Yacubovich
body: Hello [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) ,

Thank you for your response. I am attaching items 2 and 3. I am not sure anything above that will help to debug the issue. As you can see in the screenshot, I am setting the varTarget to the value of lookupIssues, and in the log I can see that it is set correctly.

Thakn you!

![Untitled 2.png](https://community.atlassian.com/t5/image/serverpage/image-id/349106i6E07636BD7D1F152/image-size/large?v=v2&px=999 "Untitled 2.png")![Untitled 3.png](https://community.atlassian.com/t5/image/serverpage/image-id/349107i0E3425866F4789E8/image-size/large?v=v2&px=999 "Untitled 3.png")


author: Trudy Claspill
body: I don't believe that the Link Issue action can take multiple issue keys as an input. The documentation implies that you can create a link to a single issue.

<https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Link-issues>

The reason I asked to see your entire rule was so that its current construction would inform any recommendation I made to you concerning how to link to multiple issues.


author: David Yacubovich
body: [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) attached the complete flow.

Thank you in advance!

![Part-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/349120iEE828DACDD24697F/image-size/large?v=v2&px=999 "Part-1.png")![Part-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/349119i16CA4B5066A53893/image-size/large?v=v2&px=999 "Part-2.png")![Part-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/349121iCAE23A0037F9D3D4/image-size/large?v=v2&px=999 "Part-3.png")


author: Trudy Claspill
body: Thank you, that is helpful.

My initial suggestion was going to be to use a branch to iterate through the results of your Lookup Issues action and link each one to the newly created issue. Unfortunately you rule is already in a branch at that point, and you cannot nest a branch within a branch.

Thinking out loud....

I wonder if there might be a clever solution here where you

1. Create a variable to contain the JQL of that the Lookup Issues action that gets the issues you want to link to the new issue.

2. You create a another rule that uses a webhook as its trigger.

3. Where you have the Link Issue action, you replace that with a Send Web Request action which you use to call the webhook of the new rule. In that webhook call you provide the JQL variable and the issue key of the newly created issue as parameters.

4. In that second rule, your run a Lookup Issue action to execute the supplied JQL.

5. In that rule you use a branch to iterate through those results, linking each one to the newly created issue, which you have supplied as another parameter when you called the rule's webhook.

I haven't actually tried this out. A colleague of mine recently created a rule that needed to call a JIRA API endpoint that will need multiple calls because the data will be paginated. He set up another rule with a webhook trigger and called it from the first rule to get the next page of data. He provided data to the rule's webhook to tell it how to make the next API call for the next page of data.


Tags: cloud

jira-cloud