Global automation: Two "For each" in the same automation with the trigger being "Version released"
Asked by Cl?udia Silva:

**Goal:** In a x,y and z project, when a version is released, I want it to go to issues and for each issue present in the issues links -\> in the "is validated by" type, I want these linked issues to be cloned.

However, there are several problems in the various tests I did. Firstly, I realized that if the trigger is "version released", then the only options I have are to put the for:JQL condition or for: Issues fixed in version, the issue is that after entering In the issues associated with the version, I cannot create a new for to run through each issue link and clone this one..  
Is there any way to get around this situation?

A note: linked issues are from a different project than issues from the released version.  
Thank you very much!

1.The first screen shot would be the ideal flow, in which I could go to related issues and clone them:

![1st attempt.png](https://community.atlassian.com/t5/image/serverpage/image-id/324516iE1CEDC066D77E030/image-size/large?v=v2&px=999 "1st attempt.png")

2. The second screen shot is to start with for permitted -\> for: Issues fixed in version, however I can't put another for...![2nd attempt.png](https://community.atlassian.com/t5/image/serverpage/image-id/324517i3B80C9866EED337A/image-size/large?v=v2&px=999 "2nd attempt.png")


Answers:
author: Rudy Holtkamp
body: Hi [@Cl?udia Silva](/t5/user/viewprofilepage/user-id/5056478)

You can use a smart value condition with:

```
{{version.project.key}}

exactly matches regular expression

PRONE|PRTWO|PRTHREE
```

For the for loop you can use branch / related issues =\> JQL

For the JQL you can use:

```
fixVersion = {{version}} and fixversion IN releasedVersions()
```

This should tackle the problems you described.

Good luck,

Rudy

comments: author: Cl?udia Silva
body: First of all, thank you for the brief response [@Rudy Holtkamp](/t5/user/viewprofilepage/user-id/636802) !

Is it necessary to use ScriptRunner for JQL? This is because I don't have this plugin and when I put this expression, I can't validate the query... Since I created the version variable previously..

But there is a problem here, it is that the linked issues do not have an associated fixVersion and cannot have one because they are like general issues that can be associated with many versions.. that is why I needed to clone these issues and then associate the version.

Thank you!!

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


author: Rik de Valk
body: Hi [@Cl?udia Silva](/t5/user/viewprofilepage/user-id/5056478) ,

It is not possible to create a nested loop unfortunately. So you will need to find a workaround for this.

For example, you work with 2 rules.

1. Rule one triggers on Version Released and adds a label 'released' to each issue in the release
2. Rule two triggers on a Field Change (Label) and has a condition that Labels contains 'released' and
   1. Finds the 'validated by' issue and clones it
   2. Removes the Label 'released' (to prevent this rule to fire a next time a label is changed)

Hope that helps.

Have a nice day! Rik

comments: author: Cl?udia Silva
body: First of all, thank you very much for the brief response [@Rik de Valk](/t5/user/viewprofilepage/user-id/628286) !

It really is an alternative, I will have to create two issues and add a specific field for the "released" label situation, but it works for clone issues. Thank you very much!


Tags: cloud

jira-service-management

jira-service-management-cloud