---
title: "Tutorial on using Closures"
canonical: "https://support.appfire.com/space/JMWE/462160400/Tutorial%20on%20using%20Closures"
format: markdown
---
> Macro (aura-html)

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


**On this page:**


# <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 Closure 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 Closure 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 >> [Perform an action based on the value of a field](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461473102)