---
title: "Tutorial on looping over collections"
canonical: "https://support.appfire.com/space/JMWE/462062361/Tutorial%20on%20looping%20over%20collections"
format: markdown
---
> Macro (aura-html)

> Macro (excerpt)
> 
> <span style="color: #333333">This tutorial will guide you through writing Groovy scripts that loop over collections.</span>

> ℹ️ The snippets in this tutorial can be further simplified using [Closures](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461702257), explained in the next tutorial.

**<span style="color: #333333">On this page:</span>**


# <span style="color: #333333">Looping over a collection to find values that satisfy a condition</span>

<span style="color: #333333">This section of the tutorial guides you through writing a loop to count the options of a multi-valued field that satisfy a condition. Imagine a functional use case where you want to display the number of released versions for a project.</span>

## Writing the script

### Step 1 - Navigate to the condition

1. Go to the **Administration** icon > Macro (inline-media-image)

 and click on it.
2. Locate **Add-ons** from the menu and click on it.
3. Locate **JIRA MISC WORKFLOW EXTENSIONS** on the left panel.
4. Click on [Groovy script tester](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78056956).

### Step 2 - Write the script in the editor

1. <span style="color: #333333">Write the following script in the editor.</span>

### Step 3 - <span style="color: #333333">Test your script</span>

1. <span style="color: #333333">Click on</span><span style="color: #333333"> </span>`Test Groovy Script`<span style="color: #333333">.</span>
2. <span style="color: #333333">Input the issue key</span><span style="color: #333333"> </span>`GIJ-1`
3. <span style="color: #333333">Click on</span><span style="color: #333333"> </span>`Test`
4. <span style="color: #333333">The following result will be displayed.</span>

# <span style="color: #333333">Looping over a collection to find whether a particular option is selected or not</span>

<span style="color: #333333">This section of the tutorial guides you through writing a loop to find whether a particular check box of a check box type field is selected or not. Imagine a functional use case where you want check whether Printing has been scheduled in the tasks.</span>

## Writing the script

### Step 1 - Navigate to the condition

1. Go to the **Administration** icon > Macro (inline-media-image)

 and click on it.
2. Locate **Add-ons** from the menu and click on it.
3. Locate **JIRA MISC WORKFLOW EXTENSIONS** on the left panel.
4. Click on [Groovy script tester](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78056956).

### Step 2 - Write the script in the editor

1. <span style="color: #333333">Write the following script in</span>`Groovy script`<span style="color: #333333">.</span>

### Step 3 - <span style="color: #333333">Test your script</span>

1. <span style="color: #333333">Click on</span><span style="color: #333333"> </span>`Test Groovy Script`<span style="color: #333333">.</span>
2. <span style="color: #333333">Input the issue key</span><span style="color: #333333"> </span>`GIJ-1`
3. <span style="color: #333333">Click on</span><span style="color: #333333"> </span>`Test`
4. <span style="color: #333333">The following result will be displayed.</span>
5. > Macro (inline-media-image)

### Next >> [Using Closures](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/462160400)