---
title: "Native Iterations"
canonical: "https://docs.getxray.app/space/XRAY/159678710/Native%20Iterations"
format: markdown
---
> Macro (ui-expand)
> 
> > Macro (toc)

# <span style="color: #000000">Introduction</span>

<span style="color: #000000">In this page, it's explained how to export a property when it has more than a single value.</span>

<span style="color: #000000">The </span>[<span style="color: #000000">Xray Document Generator</span>](https://getxraydocs.atlassian.net/wiki/display/XRAY/Document+Generator)<span style="color: #000000"> also provides data filtering and sorting directly on the iteration definition.</span>

# Operations

## Issues

### Issue Activity

Changes to Issues are registered in the Issue Activity, but it is not known in advance how many changes are going to be made. You can iterate a section over all the activities of an Issue. This allows you to create a table that dynamically grows according to the number of existing activities. The notation is:

| **Activity Fields** | **Description** |
| --- | --- |
| Title | The title of the Issue |
| Summary | The summary of the activity |
| Content | When an activity involves a change in the Issue contents, this field displays the new contents |
| Author | The author of the activity |
| AuthorEmail | The email of the author of the activity |
| Published | The time when the Issue was published |
| Updated | The time when the Issue was updated |
| Categories | When an activity regards an Issue Status change, this field displays the new Issue Status |

<details>
<summary>Expand to see the sample code</summary>

```
#{for activityEntries}
   ${ActivityEntries[n].Title}
   ${ActivityEntries[n].Summary}
   ${ActivityEntries[n].Content}
   ${ActivityEntries[n].Author}
   ${ActivityEntries[n].AuthorEmail}
   ${dateformat("dd-MM-yyyy HH:mm:ss"):ActivityEntries[n].Published}
   ${dateformat("dd-MM-yyyy HH:mm:ss"):ActivityEntries[n].Updated}
   ${ActivityEntries[n].Categories}
#{end}
 
or
 
#{for <VariableName>=ActivityEntriesCount}
   Content and Issue Mappings. Example: ${ActivityEntries[VariableName].Field}
#{end}
```
</details>

> ℹ️ We suggest using the **HTML function** to render the data because almost all content is HTML, e.g., `${html:ActivityEntries[n].Title}`

Below are two examples of using the Activity iteration in a Word and Excel template:

> Macro (inline-media-image)

 

> Macro (inline-media-image)

<span style="color: #000000"> </span>

### <span style="color: #000000">Issue History</span>

<span style="color: #000000">You can iterate a section over all the history entries of an Issue. This allows you to create a table that dynamically grows according to the number of changes done. </span>

#### <span style="color: #000000">Exportable Data</span>

| <span style="color: #000000">**Field**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000">HistoryEntriesCount</span> | <span style="color: #000000">Returns the number of changes made</span> |
| <span style="color: #000000">Author</span> | <span style="color: #000000">Returns the user who made the change</span> |
| <span style="color: #000000">Created</span> | <span style="color: #000000">Date of the change</span> |
| <span style="color: #000000">TestVersion</span> | <span style="color: #000000">In the case of Xray Tests, it outputs the Test version where the change was made (if applicable)</span> |
| <span style="color: #000000">ChangedItemsCout</span> | <span style="color: #000000">Returns the number of fields changed in the current change</span> |
| <span style="color: #000000">ChangedItem</span> | > Macro (nested-table) |


<span style="color: #000000">The notation is:</span>

<details>
<summary>Expand to see the sample code</summary>

```
#{for historyEntries}
   ${fullname:HistoryEntries[n].Author} made changes ${dateformat("dd-MM-yyyy HH:mm:ss"):HistoryEntries[n].Created}
  #{for ch=HistoryEntries[n].ChangedItemsCount}
	Field Name: ${HistoryEntries[n].ChangedItems[ch].Field}
	Old Value:  ${HistoryEntries[n].ChangedItems[ch].From}
	New Value:  ${HistoryEntries[n].ChangedItems[ch].To}
  #{end} 
#{end}
 
or
 
#{for h=HistoryEntriesCount}
   ${fullname:HistoryEntries[h].Author} made changes    ${dateformat("dd-MM-yyyy HH:mm:ss"):HistoryEntries[h].Created}
   #{for ch=HistoryEntries[h].ChangedItemsCount}
	Field Name: ${HistoryEntries[h].ChangedItems[ch].Field}
	Old Value:  ${HistoryEntries[h].ChangedItems[ch].From}
	New Value:  ${HistoryEntries[h].ChangedItems[ch].To}
   #{end} 
#{end}
```
</details>

### <span style="color: #000000">Issue Links</span>

<span style="color: #000000">Because it is not known in advance how many linked Issues exist for an Issue, you can iterate a section over all the linked Issues of an Issue. This allows you to create a table that dynamically grows according to the number of existing linked Issues. </span>

#### <span style="color: #000000">Exportable Data</span>

| <span style="color: #000000">**Field**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000"> </span>**<span style="color: #000000">AppType</span>**<span style="color: #000000"> </span> | <span style="color: #000000">Returns the Application Type. The values can be:</span><br>> Macro (nested-table) |
| <span style="color: #000000"> </span>**<span style="color: #000000">LinkType</span>**<span style="color: #000000"> </span> | <span style="color: #000000">Returns the Link Type</span> |

> ℹ️ <span style="color: #000000">When the link you are iterating is of </span>*<span style="color: #000000">AppTypes External Jira</span>***<span style="color: #000000"> </span>**<span style="color: #000000">or</span>**<span style="color: #000000"> </span>***<span style="color: #000000">Confluence</span>*<span style="color: #000000">, the name is obtained using the </span>*<span style="color: #000000">Summary</span>*<span style="color: #000000"> property.</span>


<span style="color: #000000">The notation is:</span>

<details>
<summary>Expand to see the sample code</summary>

```
#{for links}
   ${Links[n].AppType}
   ${Links[n].LinkType}
   ${Links[n].Key}
   ${Links[n].Summary}
   ${Links[n].URL}
#{end}
 
or
 
#{for <VariableName>=LinksCount}
   Content and Linked Issue Mappings. Example: ${Links[VariableName].Field}
#{end}
```
</details>

<span style="color: #000000">The documents below demonstrate an example of a template that iterates over linked Issues.</span>

> Macro (inline-media-image)

 

> Macro (inline-media-image)

<span style="color: #000000"> </span>

### <span style="color: #000000">Issue Comments</span>

<span style="color: #000000">Because it is not known in advance how many comments exist for an Issue, you can iterate a section over all the comments on an Issue. This allows you to create a table that dynamically grows according to the number of existing comments. The notation is:</span>

| <span style="color: #000000">**Comments Fields**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000">Author</span> | <span style="color: #000000">The author of the comment</span> |
| <span style="color: #000000">AuthorFullName</span> | <span style="color: #000000">The full name of the author of the comment</span> |
| <span style="color: #000000">Body</span> | <span style="color: #000000">The comment</span> |
| <span style="color: #000000">Created</span> | <span style="color: #000000">The date the comment was posted</span> |
| <span style="color: #000000">GroupLevel</span> | <span style="color: #000000">The group level of the comment</span> |

<details>
<summary>Expand to see the sample code</summary>

```
#{for comments}
   ${Comments[n].Author} 
   ${Comments[n].AuthorFullName} 
   ${Comments[n].Body} 
   ${dateformat("dd-MM-yyyy HH:mm:ss"):Comments[n].Created}
   ${Comments[n].GroupLevel}
#{end}
 
or
 
#{for <VariableName>=CommentsCount}
   Content and Issue Mappings. Example: ${Comments[VariableName].Field}
#{end}
```
</details>

<span style="color: #000000">The documents below demonstrate an example of a Word template that iterates over Issue comments.</span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

### <span style="color: #000000">Issue Worklogs</span>

<span style="color: #000000">Because it is not known in advance how many worklogs exist for an Issue, you can iterate a section over all the worklogs of an Issue. This allows you to create a table that dynamically grows according to the number of existing worklogs. The notation is:</span>

| <span style="color: #000000">**Worklogs Fields**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000">Author</span> | <span style="color: #000000">The author of the worklog</span> |
| <span style="color: #000000">AuthorFullName</span> | <span style="color: #000000">The full name of the author of the worklog</span> |
| <span style="color: #000000">Comment</span> | <span style="color: #000000">The comment of the worklog</span> |
| <span style="color: #000000">Created</span> | <span style="color: #000000">The date the worklog was created</span> |
| <span style="color: #000000">Date Started</span> | <span style="color: #000000">The date the worklog was started</span> |
| <span style="color: #000000">Time Spent</span> | <span style="color: #000000">The time spent in seconds</span> |
| <span style="color: #000000">TimeSpentFormatted</span> | <span style="color: #000000">The time spent as displayed on Jira</span> |
| <span style="color: #000000">BilledHours</span> | <span style="color: #000000">The billed hours in seconds (belongs to the </span>[<span style="color: #000000">Tempo Timesheets plugin</span>](https://marketplace.atlassian.com/apps/6572/timesheets-by-tempo-jira-time-tracking)<span style="color: #000000">)</span> |
| <span style="color: #000000">BilledHoursFormatted</span> | <span style="color: #000000">The billed hours as displayed on Jira (belongs to the Tempo Timesheets plugin)</span> |

<details>
<summary>Expand to see the sample code</summary>

```
#{for worklogs}
   ${Worklogs[n].Author} 
   ${Worklogs[n].AuthorFullName} 
   ${Worklogs[n].Comment}
   ${dateformat("dd-MM-yyyy HH:mm:ss"):Worklogs[n].Created}
   ${dateformat("dd-MM-yyyy HH:mm:ss"):Worklogs[n].Date Started} 
   ${Worklogs[n].Time Spent}
   ${Worklogs[n].TimeSpentFormatted} 
#{end}
 
or
 
#{for <VariableName>=WorklogsCount}
   Content and Worklog Mappings. Example: ${Worklogs[VariableName].Field}
#{end}
```
</details>

### <span style="color: #000000">Issue SubTasks</span>

<span style="color: #000000">Because it is not known in advance how many Subtasks exist for an Issue, you can iterate a section over all the Subtasks of an Issue. This allows you to create a table that dynamically grows according to the number of existing subtasks. The notation is:</span>

| <span style="color: #000000">**Subtasks Fields**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000">Key</span> | <span style="color: #000000">The key to the Subtasks</span> |
| <span style="color: #000000">Summary</span> | <span style="color: #000000">The summary of the Subtasks</span> |
| <span style="color: #000000">AssigneeUserDisplayName</span> | <span style="color: #000000">The assignee user of the Subtasks</span> |

<details>
<summary>Expand to see the sample code</summary>

```
#{for subtasks}
   ${Subtasks[n].Key}
   ${Subtasks[n].Summary}
   ${Subtasks[n].AssigneeUserDisplayName}
#{end}
 
or
 
#{for <VariableName>=SubtasksCount}
   Content and Issue Mappings. Example: ${Subtasks[VariableName].Field}
#{end}
```
</details>

<span style="color: #000000">The documents below demonstrate an example of a template that iterates over Issue Subtasks.</span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

<span style="color: #000000">For an example of how to iterate the details of a subtask Parent Issue, please check the Iterating JQL Queries area below.</span>

### <span style="color: #000000">Issue Components</span>

<span style="color: #000000">Because it is not known in advance how many components exist for an Issue, you can iterate a section over all the components of an Issue. This allows you to create a table that dynamically grows according to the number of existing components. The notation is:</span>

| <span style="color: #000000">**Components Fields**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000">Name</span> | <span style="color: #000000">The name of the component</span> |
| <span style="color: #000000">Description</span> | <span style="color: #000000">The description of the component</span> |
| <span style="color: #000000">Lead</span> | <span style="color: #000000">The name of the component lead</span> |
| <span style="color: #000000">Id</span> | <span style="color: #000000">The ID of the component</span> |
| <span style="color: #000000">ProjectId</span> | <span style="color: #000000">The project ID of the component</span> |
| <span style="color: #000000">AssigneeType</span> | <span style="color: #000000">The assignee type of the component</span> |

<details>
<summary>Expand to see the sample code</summary>

```
#{for components}
   ${Components[n].Name}
   ${Components[n].Description}
   ${fullname:Components[n].Lead}
   ${Components[n].Id}
   ${Components[n].ProjectId}
   ${Components[n].AssigneeType}
#{end}
```
</details>

<span style="color: #000000"> The documents below demonstrate an example of a template that iterates over Issue components.</span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

### <span style="color: #000000">Issue Status Transitions</span>

<span style="color: #000000">Because it is not known in advance how many Status Transitions exist for an Issue, you can iterate a section over all the Status Transitions of an Issue. This allows you to create a table that dynamically grows according to the number of existing status transitions. The notation is:</span>

| <span style="color: #000000">**Status Transitions Fields**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000">Author</span> | <span style="color: #000000">The author of the status transition</span> |
| <span style="color: #000000">Created</span> | <span style="color: #000000">The date the status transition was performed</span> |
| <span style="color: #000000">OldStatus</span> | <span style="color: #000000">The old status of the status transition</span> |
| <span style="color: #000000">NewStatus</span> | <span style="color: #000000">The new status of the status transition</span> |

<details>
<summary>Expand to see the sample code</summary>

```
#{for statusTransitions}
   ${StatusTransitions[n].Author}
   ${dateformat("dd-MM-yyyy HH:mm:ss"):StatusTransitions[n].Created}
   ${StatusTransitions[n].OldStatus}
   ${StatusTransitions[n].NewStatus}
#{end}
 
or
 
#{for <VariableName>=StatusTransitionsCount}
   Content and StatusTransitions Mappings. Example: ${StatusTransitions[VariableName].Field}
#{end}
```
</details>

<span style="color: #000000">The documents below demonstrate an example of a template that iterates over status transitions.</span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

### <span style="color: #000000">Issue Attached Images</span>

<span style="color: #000000">Because it is not known in advance how many Images can exist for an Issue (as an attachment), you can iterate a section over all the attached images of an Issue to get some metadata about them. This allows you to create a table that dynamically grows according to the number of existing images. The notation is:</span>

| <span style="color: #000000">**Attachments Images Fields**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000">ID</span> | <span style="color: #000000">The ID of the attached image</span> |
| <span style="color: #000000">Image</span> | <span style="color: #000000">The image of the attached image</span> |
| <span style="color: #000000">Name</span> | <span style="color: #000000">The name of the attached image</span> |
| <span style="color: #000000">Size</span> | <span style="color: #000000">The size of the attached image</span> |
| <span style="color: #000000">HumanReadableSize</span> | <span style="color: #000000">The size of the attached image</span> |
| <span style="color: #000000">Author</span> | <span style="color: #000000">The author of the attached image</span> |
| <span style="color: #000000">Created</span> | <span style="color: #000000">The date the attached image was created</span> |
| <span style="color: #000000">MimeType</span> | <span style="color: #000000">The type of the attached image</span> |
| <span style="color: #000000">ThumbnailURL</span> | <span style="color: #000000">The URL to the thumbnail of the image</span> |

<details>
<summary>Expand to see the sample code</summary>

```
#{for images}
   ${Images[n].Image|maxwidth=150|maxheight=150}
   ${Images[n].Name}
   ${Images[n].ID}
   ${Images[n].Size}
   ${Images[n].HumanReadableSize}
   ${Images[n].Author}
   ${dateformat("dd-MM-yyyy HH:mm:ss"):Images[n].Created}
   ${Images[n].MimeType}
   ${Images[n].ThumbnailURL}
 #{end}
 
or
 
#{for <VariableName>=ImagesCount}
   Content and Images Mappings. Example: ${Images[VariableName].Field}
#{end}
```
</details>

<span style="color: #000000">The document below demonstrates an example of a Word template that iterates over attached images. </span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>


> ℹ️ <span style="color: #000000">The </span>[<span style="color: #000000">Xray Document Generator</span>](https://getxraydocs.atlassian.net/wiki/display/XRAY/Document+Generator)<span style="color: #000000"> will automatically read the EXIF orientation property of an image and rotate it to its correct orientation. You can disable this by adding </span>[<span style="color: #000000">this property</span>](https://getxraydocs.atlassian.net/wiki/spaces/XRAY/pages/301413056)<span style="color: #000000"> to your template.</span>

<details>
<summary>Expand to see the sample code</summary>

```
#{for images}
   ${Images[n].Image|width=150|height=150}
 #{end}
```
</details>

<span style="color: #000000">These values are in pixels and if you only define one of them the image will be rescaled.</span>

> ℹ️ <span style="color: #000000">If you use both maxWidth and width mappings, only the max value will be read. The same behavior happens with height and maxHeight.</span>

<span style="color: #000000">The document below demonstrates an example of an Excel template that iterates over attached images.  </span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

### <span style="color: #000000">Issue Attachments</span>

<span style="color: #000000">Because it is not known in advance how many attachments exist in an Issue, you can iterate a section over all the attachments of an Issue. This allows you to create a table that dynamically grows according to the number of existing attachments. The notation is:</span>

| <span style="color: #000000">**Attachments Fields**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000">ID</span> | <span style="color: #000000">The ID of the attachment</span> |
| <span style="color: #000000">Name</span> | <span style="color: #000000">The name of the attachment</span> |
| <span style="color: #000000">Author</span> | <span style="color: #000000">The author of the attachment</span> |
| <span style="color: #000000">AuthorFullName</span> | <span style="color: #000000">The full name of the author of the attachment</span> |
| <span style="color: #000000">Created</span> | <span style="color: #000000">The date the attachment was created</span> |
| <span style="color: #000000">Size</span> | <span style="color: #000000">The size of the attachment</span> |
| <span style="color: #000000">HumanReadableSize</span> | <span style="color: #000000">The formatted size of the attachment</span> |
| <span style="color: #000000">MimeType</span> | <span style="color: #000000">The type of attachment</span> |

<details>
<summary>Expand to see the sample code</summary>

```
#{for attachments}
   ${Attachments[n].ID}
   ${Attachments[n].Name}
   ${Attachments[n].Author}
   ${Attachments[n].AuthorFullName}
   ${dateformat("dd-MM-yyyy HH:mm:ss"):Attachments[n].Created}
   ${Attachments[n].Size}
   ${Attachments[n].HumanReadableSize}
   ${Attachments[n].MimeType}
#{end}
 
or
 
#{for <VariableName>=AttachmentsCount}
   Content and Issue Mappings. Example: ${Attachments[VariableName].Field}
#{end}
```
</details>

<span style="color: #000000">The documents below demonstrate an example of a template that iterates over attachments.</span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

### <span style="color: #000000">Issue Labels</span>

<span style="color: #000000">Because it is not known in advance how many labels exist in an Issue, you can iterate a section over all the labels of an Issue. The notation is:</span>

| <span style="color: #000000">**Attachments Fields**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000">Name</span> | <span style="color: #000000">The name of the label</span> |

```
#{for labels}
   ${Labels[n].Name}
#{end}
 
or
 
#{for <VariableName>=LabelsCount}
  ${Labels[VariableName].Name}
#{end}
```

<span style="color: #000000">The documents below demonstrate an example of a template that iterates over labels.</span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

### <span style="color: #000000">Project Versions</span>

<span style="color: #000000">You can iterate over all project versions to which the Issue belongs. The notation is:</span>

| <span style="color: #000000">**Attachments Fields**</span> | <span style="color: #000000">**Description**</span> |
| --- | --- |
| <span style="color: #000000">Name</span> | <span style="color: #000000">The name of the project version</span> |
| <span style="color: #000000">Description</span> | <span style="color: #000000">The description of the project version</span> |
| `Start date` | <span style="color: #000000">The start date of the project version</span> |
| `Release date` | <span style="color: #000000">The release date of the project version</span> |

```
#{for projectVersions}
   ${ProjectVersions[n].Name}
   ${ProjectVersions[n].Description}
   ${dateformat("dd-MM-yyyy"):ProjectVersions[n].Start date}
   ${dateformat("dd-MM-yyyy"):ProjectVersions[n].Release date}
#{end}
 
or
 
#{for <VariableName>=ProjectVersionsCount}
   ${ProjectVersions[VariableName].Name}
   ${ProjectVersions[VariableName].Description}
   ${dateformat("dd-MM-yyyy"):ProjectVersions[VariableName].Start date}
   ${dateformat("dd-MM-yyyy"):ProjectVersions[VariableName].Release date}
#{end}
```

<span style="color: #000000">The documents below demonstrate an example of a template that iterates over the project version.</span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

## <span style="color: #000000">Iterations</span>

### <span style="color: #000000">Iterating JQL Queries</span>

<span style="color: #000000">You can iterate Issues that are the result of a </span>[<span style="color: #000000">JQL Query</span>](https://confluence.atlassian.com/display/JIRA/Advanced+Searching#AdvancedSearching-WhatisanAdvancedSearch?)<span style="color: #000000">. The syntax is similar to the other iterations, but there is a </span>**<span style="color: #000000">clause</span>**<span style="color: #000000"> parameter that will receive the JQL Query. A few examples are provided below.</span>

<details>
<summary>Expand to see the sample code</summary>

```
a simple example iterating the details of issues from a specified Project:
 
#{for i=JQLIssuesCount|clause=project = DEMO}
   ${JQLIssues[i].Key}
   ${JQLIssues[i].Summary} 
#{end}

or a more advanced example iterating the details of issues linked with the current Issue:
 
#{for m=JQLIssuesCount|clause=issuekey in linkedIssues (${Links[j].Key})}
   Linked Issue ${JQLIssues[m].Summary} has ${JQLIssues[m].LinksCount} links
#{end} 
 
or an also advanced example iterating the details of the Parent issue from the current Subtask:
 
#{for i=JQLIssuesCount|clause=issuekey = ${ParentIssueKey}}
	${JQLIssues[i].Key}
	${JQLIssues[i].Id}
	${JQLIssues[i].Description}
#{end}


```
</details>


<span style="color: #000000">The documents below demonstrate an example of a template that iterates over Issue Subtasks.</span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>  
<span style="color: #000000"> </span>

> ℹ️ <span style="color: #000000">You can also use a </span>[<span style="color: #000000">Filter Name or a Filter ID as a clause</span>](https://getxraydocs.atlassian.net/wiki/spaces/XRAY/pages/160235809)<span style="color: #000000">.</span>

### <span style="color: #000000">Applying Filters to Iterations</span>

<span style="color: #000000">If you want to take the previous iterations over Comments, Subtasks, and Issue links to another level of control, you can use a JavaScript filter to define over which Issues the iteration will be made. This can be useful in the following scenarios:</span>

- <span style="color: #000000">Iterating over linked Issues that are only of a specific Issue Type.</span>
- <span style="color: #000000">Iterating over subtasks of a specific Issue Type.</span>
- <span style="color: #000000">Iterating over linked Issues with a specific priority.</span>
- <span style="color: #000000">Iterating over Comments created by a specific user.</span>

<span style="color: #000000">The notation for applying filters to the iterations is:</span>

<details>
<summary>Expand to see the sample code</summary>

```
#{for <VariableName>=<LinksCount|SubtasksCount|CommentsCount|WorklogsCount>|filter=%{<Javascript>}}
   Content here
#{end}
```
</details>

- <span style="color: #000000"> </span><u><span style="color: #000000"> </span></u>**<span style="color: #000000">VariableName</span>**<span style="color: #000000"> is the name of the variable to use as the iteration index.</span>
- <span style="color: #000000"> </span><u><span style="color: #000000"> </span></u>**<span style="color: #000000">LinksCount|SubtasksCount|CommentsCount </span>**<span style="color: #000000">indicates which type of entities you want to iterate.</span>
- <span style="color: #000000"> </span>**<span style="color: #000000">Filter</span>**<span style="color: #000000"> indicates the filter to be applied in the iteration.</span>

<span style="color: #000000">The filter is evaluated as a JavaScript expression, which provides flexibility in the definition of the conditions. You can use </span>`and (&&)`<span style="color: #000000">, or (||) and other logical operators supported by the JavaScript language.</span>

<span style="color: #000000">It is also possible to format fields inside iteration filters.</span>

<span style="color: #000000">The image below demonstrates an example of a template that iterates over Issue links and comments with filters being applied.</span>

<span style="color: #000000">Links Bugs with High Priority:</span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

<span style="color: #000000">Nested Iterations:</span>

> Macro (inline-media-image)

<span style="color: #000000"> </span>

### <span style="color: #000000">Iterating in the Same Line of the Document</span>

It is also possible to iterate values within the same line of the document. This can be useful if you want to display a list of subtasks or linked issues on the same line, separated by commas or spaces.

<details>
<summary>Expand to see the sample code</summary>

```
Users that added comments to this issue: #{for comments}${Comments[n].Author} #{end}

Subtasks of this issue: #{for j=SubtasksCount}${Subtasks[j].Key};#{end}

Linked issues this issue duplicates: #{for j=LinksCount|filter=%{'${Links[j].LinkType}'.equals('duplicates')}}${Links[j].Key} #{end}
```
</details>

### <span style="color: #000000">Iterating in the Same Cell of an Excel Document</span>

<span style="color: #000000">You can also iterate values in the same cell of an Excel document. You can achieve this by simply making your Iteration inside the same cell.</span>

<span style="color: #000000">You can use all the Iterations that you are used to and construct them in the same way, the difference being that you only use one cell to execute them.</span>

<details>
<summary>Expand to see the sample code</summary>

```
Issue iteration as a demonstration.
Copy this iteration below and paste it into a cell.
 
&{for issues} ${Key} &{end}
```
</details>

### <span style="color: #000000">Iterating with the BREAK or CONTINUE Statement</span>

<span style="color: #000000">You can iterate anything, set up a Conditional expression, and then utilize the BREAK and CONTINUE statements.</span>

<span style="color: #000000">The way to do this is by doing a normal Conditional expression and using the mapping </span>`#{break}`<span style="color: #000000"> or </span>`#{continue}`<span style="color: #000000"> inside it. </span>

<details>
<summary>Expand to see the sample code</summary>

```
Imagine that you have a Jira Issue that contains these comments:
- Hello
- World
- Greetings
- Hi
 
For the Break functionality, lets say that you want to stop the iteration if the current comment is "World". Here is the template for that:
#{for comments}
Current Comment: ${Comments[n].Body}
#{if (%{'${Comments[n].Body}'.equals('World')})}
#{break}
#{end}
Current Comment Author: ${Comments[n].Author}
#{end}
In this case, it will print the comment "Hello" and it´s author. Next it will print the comment Body "World" but since the Conditional expression is true, it will stop the iteration all together and not print anything else.
Note: Anything after the #{break} mapping will not be printed in the exported document.
 
For the Continue functionality, lets say that you want to skip to the next iteration if the current comment is "World", bypassing the Author mapping for this iteration. Here is the template for that:
#{for comments}
Current Comment: ${Comments[n].Body}
#{if (%{'${Comments[n].Body}'.equals('World')})}
#{continue}
#{end}
Current Comment Author: ${Comments[n].Author}
#{end}
In this case, it will print the comment "Hello" and it´s author. Next, it will print the comment Body "World" but since the Conditional expression is true, it will continue to the next iteration, not printing the Author of the "World" comment.
```
</details>

### <span style="color: #000000">Iterating Parent Issues</span>

<span style="color: #000000">You can iterate a section over all the parent issues of an Issue. This allows you to create a table that dynamically grows according to the information you want to see from parent Issues.</span>

<span style="color: #000000">Imagine that you have a Jira Issue that contains a Key, Summary, Description, and further information. From now on, you are able to get all the information from a parent issue. To get those fields, you just need to have the following definition: </span>`${Parent.<Field>}`

Example:

<details>
<summary>Expand to see the sample code</summary>

```
&{for issues|filter=%{'${IssueTypeName}'.equals('Sub-task')}}
   ${Parent.Key}
   ${Parent.Summary}
   ${Parent.Description}
   ${wiki:Parent.Description}
   ${html:Parent.Description}
   ${dateformat(“dd-MM-yyyy HH:mm:ss”):Parent.date}
   ${emailaddress:Parent.userpicker}
&{end}

This example only has a few fields, but this new feature allows you to get all information from a parent issue.
```
</details>

### <span style="color: #000000">Sorting Iterations</span>

<span style="color: #000000">Imagine that you have an iteration and want to sort it by any field that it can export normally. This will be the header for such an iteration: </span>`#{for comments|sortby=<Iteration mapping>}`

> ℹ️ <span style="color: #000000">The mapping after the </span>*<span style="color: #000000">sortby</span>*<span style="color: #000000"> must be equal to the supported mappings for each Iteration.</span>

Example:

<details>
<summary>Expand to see the sample code</summary>

```
This iteration will be sorted by the Body of all the comments in the issue.

#{for comments|sortby=Body}
${Comments[n].Author}
${Comments[n].Body}
#{end}
```
</details>

#### <span style="color: #000000">Sort By on multi-Issue Export</span>

<span style="color: #000000">The </span>*<span style="color: #000000">sortby</span>*<span style="color: #000000"> can also be used to sort a </span>*<span style="color: #000000">&{for issues}</span>*<span style="color: #000000"> iteration on a Bulk Export.</span>

<details>
<summary>Expand to see the sample code</summary>

```
&{for issues|sortby=IssueTypeName}
${Key} - ${IssueTypeName}
&{end}
```
</details>

> ℹ️ **Sorting Criteria**
> ℹ️ 
> ℹ️ *<span style="color: #000000"> asc</span>*<span style="color: #000000"> and </span>*<span style="color: #000000">desc</span>*<span style="color: #000000"> can be defined to determine how you want to sort your data. The default value is </span>*<span style="color: #000000">asc</span>*<span style="color: #000000">.</span>

<details>
<summary>Support/Troubleshooting</summary>

If you have questions or technical issues, please [contact the Support team via the Customer Portal (Jira service management)](https://jira.getxray.app/servicedesk/customer/portal/2/user/login?destination=portal%2F2%2Fcreate%2F28) or [send us a message using the in-app chat](https://getxraydocs.atlassian.net/wiki/spaces/XRAY/pages/301501383).
</details>