---
title: "Native Iterations"
canonical: "https://docs.getxray.app/space/XRAYCLOUD/44566338/Native%20Iterations"
format: markdown
---
<details>
<summary>Table of Contents</summary>

> Macro (toc)
</details>

# Iterating Issue History

Changes to Issues are registered in the Issue History, but it is not known in advance how many changes are going to be made. 

The History tab shows the following Issue’s operations/updates:

- Changing the Test Type.
- Changing the Test Definition or Steps.
- Linking the Test with other entities (Preconditions, Test Plans, Test Sets, etc.).
- Moving the Test between folders on the Test Repository.
- Attachment addition.
- Test Execution.

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. 

The notation is:

| **Field** | **Description** |
| --- | --- |
| HistoryEntriesCount | The number of changes made |
| Author | The user who made the change |
| Created | Date of the change |
| ChangedItemsCount | The number of fields changed in the current change |
| ChangedItems | > Macro (nested-table) |

##### **Sample Code**

```
#{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 <VariableName>=HistoryEntriesCount}
   Content and Issue History Mappings. Example:${fullname:HistoryEntries[VariableName].Field}
#{end}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue comments:</span>

<span style="color: #000000">[Iterating_Issue_History (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_History.docx?version=2&modificationDate=1739980419497&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterating_Issue_History (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_History.xlsx?version=2&modificationDate=1739980517875&cacheVersion=1&api=v2)</span>

---

# Iterating Xray Issue History

Changes related to Xray fields in Xray Issues are registered in a separate tab named **Xray History, **as changes to these fields can not be included with the Issue changes. For this reason, there is another way of iterating Xray history changes. Just like with Issue changes, you can iterate a section over all the Xray history entries of an Issue. This allows you to create a table that dynamically grows according to the number of changes done.

The notation is:

| **Field** | **Description** |
| --- | --- |
| XrayHistoryEntriesCount | The number of changes made |
| Action | The action that originated the changes |
| User | The user who made the change |
| Date | Date of the change |
| Version | The Xray Test Version where the changes were made (if applicable) |
| XrayChangedItemsCount | The number of fields changed in the current change |
| XrayChangedItems | > Macro (nested-table) |

##### **Sample Code**

```
#{for XrayHistoryEntries}
   ${fullname:XrayHistoryEntries[n].User} made changes ${dateformat("dd-MM-yyyy HH:mm:ss"):XrayHistoryEntries[n].Date}
  #{for ch=XrayHistoryEntries[n].XrayChangedItemsCount}
    Field Name: ${XrayHistoryEntries[n].XrayChangedItems[ch].Field}
    Changes:  ${XrayHistoryEntries[n].XrayChangedItems[ch].Changes}
  #{end}
#{end}
  
or
  
#{for <VariableName>=XrayHistoryEntriesCount}
   Content and Xray Issue History Mappings. Example:${fullname:XrayHistoryEntries[VariableName].Field}
#{end}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue comments.</span> <span style="color: #000000"> </span>

<span style="color: #000000">[Iterating_Xray_Issue_History (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Xray_Issue_History.docx?version=2&modificationDate=1739980593478&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterating_Xray_Issue_History (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Xray_Issue_History.xlsx?version=2&modificationDate=1739980623007&cacheVersion=1&api=v2)</span>

---

# Iterating Issue Comments

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:

| **Comments Fields** | **Description** |
| --- | --- |
| Author | The author of the comment |
| AuthorFullName | The full name of the author of the comment |
| Body | The comment |
| Created | The date the comment was posted |
| GroupLevel | The group level of the comment |

##### **Sample Code**

```
#{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}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue comments.</span> <span style="color: #000000"> </span>

<span style="color: #000000">[Iterations_Comments (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Xray_Issue_History.xlsx?version=2&modificationDate=1739980623007&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterations_Comments (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Comments.xlsx?version=4&modificationDate=1739980700428&cacheVersion=1&api=v2)</span>

---

# Iterating Issue Worklogs

Because it is not known in advance how many worklogs exist for an Issue, you can iterate a section over all the work logs of an Issue. This allows you to create a table that dynamically grows according to the number of existing worklogs.

The notation is:

| **Worklogs Fields** | **Description** |
| --- | --- |
| Author | The author of the worklog |
| AuthorFullName | The full name of the author of the worklog |
| Comment | The comment on the worklog |
| Created | The date the worklog was created |
| Date Started | The date the worklog was started |
| Time Spent | The time spent in seconds |
| TimeSpentFormatted | The time spent as displayed on Jira |

##### **Sample Code**

```
#{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}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue worklogs.</span>

<span style="color: #000000">[Iterations_Worklogs (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Worklogs.docx?version=2&modificationDate=1739980739118&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterations_Worklogs (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Worklogs.xlsx?version=2&modificationDate=1739980758892&cacheVersion=1&api=v2)</span>

---

# Iterating Issue Components

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

##### **Sample Code**

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

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue components.</span>

<span style="color: #000000">[Iterating_Issue_Components (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Worklogs.xlsx?version=2&modificationDate=1739980758892&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterating_Issue_Components (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_Components.docx?version=2&modificationDate=1739980798738&cacheVersion=1&api=v2)</span>

---

# Iterating Issue Status Transitions

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

##### **Sample Code**

```
#{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}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue status transitions.</span>

<span style="color: #000000">[Iterations_Status_Transitions (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_StatusTransitions.docx?version=2&modificationDate=1739980911888&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterations_Status_Transitions (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_StatusTransitions.xlsx?version=2&modificationDate=1739980936401&cacheVersion=1&api=v2)</span>

---

# Iterating Issue Attached Images

Because it is not known in advance how many images can exist on 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 style="color: #000000">**Attachments Images Fields**</span> | **Description** |
| --- | --- |
| ID | The ID of the attached image |
| Image | The image of the attached  image |
| Name | The name of the attached image |
| Size | The size of the attached image |
| HumanReadableSize | The size of the attached image |
| Author | The author of the attached image |
| Created | The date the attached image was created |
| MimeType | The type of the attached image |
| ThumbnailURL | The image thumbnail URL. |

##### **Sample Code**

```
#{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}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue attached images.</span>

<span style="color: #000000">[Iterations_Attached_Images (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_AttachedImages.docx?version=2&modificationDate=1739980998613&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterations_Attached_Images (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_AttachedImages.xlsx?version=2&modificationDate=1739981022414&cacheVersion=1&api=v2)</span>

> ℹ️ Document Generator will automatically read the EXIF orientation property of an image and rotate it to its correct orientation. You can turn this off by adding `${prop(xporter.images.process.exif,` `true` `/` `false` `)} `to your template.

<span style="color: #000000">You can use the mappings </span>`width`<span style="color: #000000"> and </span>`height`<span style="color: #000000"> to define the exact width and height of the printed image.</span>

##### **Sample Code**

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

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

> ℹ️ If you use the `maxWidth` and `width` mappings, only the `max` value will be read. The same behavior happens with `height` and `maxHeight`.

---

# Iterating Issue Attachments

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

##### **Sample Code**

```
#{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}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue attachments.</span>

<span style="color: #000000">[Iterations_Attachments (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Attachments.docx?version=2&modificationDate=1739981124101&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterations_Attachments (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Attachments.xlsx?version=2&modificationDate=1739981146670&cacheVersion=1&api=v2)</span>

---

# Iterating Issue Labels

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

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

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue comments.</span>

<span style="color: #000000">[Iterations_Labels (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Labels.docx?version=2&modificationDate=1739981229932&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterations_Labels (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Labels.xlsx?version=2&modificationDate=1739981353174&cacheVersion=1&api=v2)</span>

---

# Iterating Fix Versions of an Issue

You can iterate over all fix versions that the Issue belongs to. 

The notation is:

| **Versions Fields** | **Description** |
| --- | --- |
| Name | The version name |
| Description | The version description |
| Start date | Starting date of the version |
| Release date | Release date of the version |
| Archived | Boolean that indicates if the version is archived or not |
| Released | Boolean that indicates if the version is released or not |

##### **Sample Code**

```
#{for FixVersions}
	${FixVersions[n].Name}
	${FixVersions[n].Description}
	${dateformat(“dd-MM-yyyy”):FixVersions[n].Start date}
	${dateformat(“dd-MM-yyyy”):FixVersions[n].Release date}
	${FixVersions[n].Archived}
	${FixVersions[n].Released}
#{end}

or

#{for <VariableName>=FixVersionsCount}
   Content and Versions Issue Mappings. Example: ${FixVersions[VariableName].Field}
#{end}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue fix versions.</span>

<span style="color: #000000">[Iterating_Issue_Fix_Versions (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_FixVersions.docx?version=2&modificationDate=1739981393024&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterating_Issue_Fix_Versions (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_FixVersions%20(1).xlsx?version=1&modificationDate=1739981419431&cacheVersion=1&api=v2)</span>

---

# Iterating Affected Versions of an Issue

You can iterate over all affected versions that the Issue belongs to. 

The notation is:

| **Versions Fields** | **Description** |
| --- | --- |
| Name | The version name |
| Description | The version description |
| Start date | Starting date of the version |
| Release date | Release date of the version |
| Archived | Boolean that indicates if the version is archived or not |
| Released | Boolean that indicates if the version is released or not |

##### **Sample Code**

```
#{for AffectedVersions}
	${AffectedVersions[n].Name}
	${AffectedVersions[n].Description}
	${dateformat(“dd-MM-yyyy”):AffectedVersions[n].Start date}
	${dateformat(“dd-MM-yyyy”):AffectedVersions[n].Release date}
	${AffectedVersions[n].Archived}
	${AffectedVersions[n].Released}
#{end}

or

#{for <VariableName>=AffectedVersionsCount}
   Content and Versions Issue Mappings. Example: ${AffectedVersions[VariableName].Field}
#{end}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue-affected versions.</span>

<span style="color: #000000">[Iterating_Issue_Affected_Versions (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_FixVersions%20(1).xlsx?version=1&modificationDate=1739981419431&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterating_Issue_Affected Versions (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_AffectedVersions.xlsx?version=2&modificationDate=1739981490195&cacheVersion=1&api=v2)</span>

---

# Iterating Project Versions

You can iterate over all project versions that the Issue belongs to.

The notation is:

| **Project Versions Fields** | **Description** |
| --- | --- |
| Name | The version name |
| Description | The version description |
| Start date | Starting date of the version |
| Release date | Release date of the version |
| Archived | Boolean that indicates if the version is archived or not |
| Released | Boolean that indicates if the version is released or not |

##### **Smaple Code**

```
#{for projectVersions}
	${ProjectVersions[n].Name}
	${ProjectVersions[n].Description}
	${dateformat(“dd-MM-yyyy”):ProjectVersions[n].Start date}
	${dateformat(“dd-MM-yyyy”):ProjectVersions[n].Release date}
	${ProjectVersions[n].Archived}
	${ProjectVersions[n].Released}
#{end}

or

#{for <VariableName>=ProjectVersionsCount}
   Content and Project Versions Mappings. Example: ${ProjectVersions[VariableName].Field}
#{end}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue project versions.</span>

<span style="color: #000000">[Iterations_Project_Versions (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_ProjectVersions.docx?version=2&modificationDate=1739981529558&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterations_Project_Versions (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_ProjectVersions.docx?version=2&modificationDate=1739981529558&cacheVersion=1&api=v2)</span>

---

# Iterating Issue Links

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. 

The notation is:

| **Links Fields** | **Description** |
| --- | --- |
| LinkType | The type of the link |
| Key | The key to the linked Issue |
| Summary | The summary of the linked Issue |
| URL | The URL of the link |

##### **Sample Code**

```
#{for links}
   ${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}
```

<span style="color: #000000">The documents below demonstrate examples both in Word and Excel templates that iterate over all the Issue links.</span>

<span style="color: #000000">[Iterations_Links (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Links.docx?version=3&modificationDate=1739981593590&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Iterations_Links (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Links.xlsx?version=3&modificationDate=1739981612654&cacheVersion=1&api=v2)</span>

---

# Iterating Issue Subtasks

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

##### **Sample Code**

```
#{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}
```

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

<span style="color: #000000">[Iterations_Subtasks (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_Links.xlsx?version=3&modificationDate=1739981612654&cacheVersion=1&api=v2)</span>

---

# Iterating Issues In Epic

<span style="color: #000000">All fields listed </span><span style="color: #000000">[here](https://docs.getxporter.app/space/XPORTERCLOUD/558575/Mappings)</span><span style="color: #000000"> are available on </span>`IssuesInEpic[n]`<span style="color: #000000"> because they represent an Issue.</span>

Because it is not known in advance how many Issues exist for an epic, you can iterate a section over all the Issues of an epic Issue. This allows you to create a table that dynamically grows according to the number of existing Issues. 

The notation is:

##### **Sample Code**

```
#{for IssuesInEpic}
   ${IssuesInEpic[n].Key}
   ${IssuesInEpic[n].Summary}
   ${IssuesInEpic[n].Description}
   ${IssuesInEpic[n].Epic Link.Key}
#{end}
 
or
 
#{for <VariableName>=IssuesInEpicCount}
   Content and Issue Mappings. Example: ${IssuesInEpic[VariableName].Field}
#{end}
```

The documents below demonstrate examples both in Word and Excel templates that iterate over the Issues in epic.

[Iterating_Issues_In_Epic (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_IssuesInEpic.docx?version=2&modificationDate=1739981865431&cacheVersion=1&api=v2)

[Iterating_Issues_In_Epic (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterations_IssuesInEpic.xlsx?version=2&modificationDate=1739981889263&cacheVersion=1&api=v2)

---

# Iterating Project Components

You can iterate over all project components.

The notation is:

##### **Sample Code**

```
#{for ProjectComponents}
   ${ProjectComponents[n].Name}
   ${ProjectComponents[n].Description}
   ${fullname:ProjectComponents[n].Lead}
   ${ProjectComponents[n].Id}
   ${ProjectComponents[n].ProjectId}
   ${ProjectComponents[n].AssigneeType}
#{end}

#{for <VariableName>=ProjectComponentsCount}
   Content and Components Mappings. Example: ${ProjectComponents[VariableName].Field}
#{end}
```

The documents below demonstrate examples both in Word and Excel templates that iterate over the project components.

[Iterating_Issue_Project_Components (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_ProjectComponents.docx?version=2&modificationDate=1739982042241&cacheVersion=1&api=v2)

[Iterating_Issue_Project_Components (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_ProjectComponents.xlsx?version=2&modificationDate=1739982069345&cacheVersion=1&api=v2)

---

# Applying Filters to Iterations

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:

- Iterating over linked Issues that are only of a specific Issue type.
- Iterating over subtasks of a specific Issue type.
- Iterating over linked Issues with a specific priority.
- Iterating over comments created by a specific user.

The notation for applying filters to the iterations is:

##### **Sample Code**

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

- <u> </u><u>**VariableName**</u><u> </u> is the name of the variable to use as the iteration index.
- <u> </u><u>**LinksCount|SubtasksCount|CommentsCount**</u><u> </u> indicates over which type of entities you want to iterate.
- **Filter** indicates the filter to be applied in the iteration.

> ℹ️ The filter is evaluated as a JavaScript expression, which provides flexibility in defining the conditions. You can use `and` (`&&`), `or` (`||`), and other logical operators supported by JavaScript.

It is also possible to format fields inside iteration filters.

The documents<span style="color: #000000"> below demonstrate examples of templates that iterate over Issue links and comments with filters being applied.</span>

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

<span style="color: #000000">[Links_With_Filter (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Iterating_Issue_ProjectComponents.xlsx?version=2&modificationDate=1739982069345&cacheVersion=1&api=v2)</span>

<span style="color: #000000">[Links_With_Filter (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Links_with_Filter.xlsx?version=2&modificationDate=1739982124644&cacheVersion=1&api=v2)</span>

**Nested Iterations:**

[Links_With_Nested_Iterations (DOCX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Links_with_Filter.xlsx?version=2&modificationDate=1739982124644&cacheVersion=1&api=v2)

[Links_With_Nested_Iterations (XLSX)](https://getxraydocs.atlassian.net/wiki/download/attachments/44828875/Links_with_nested_Iterations.docx?version=2&modificationDate=1739982161644&cacheVersion=1&api=v2)

For a working example of this functionality, check the template Sample Iterations in the [Template Store](https://store.getxporter.app/).

---

# Iterating in the Same Line of the Document

You can also iterate values in the same line of the document. This can be useful if you want to display a list of subtasks on linked Issues in the same line, separated by commas or spaces. 

##### **Sample Code**

```
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}
```

---

# Iterating in the Same Cell in an Excel Document

You can also iterate values in the same cell in an Excel document. You can achieve this by simply making your Iteration inside the same cell.

You can use all the Iterations that you are used to and construct them in the exact same way, the difference being that you only use one cell to do them.

##### **Sample Code**

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

---

# Iterating with the BREAK or CONTINUE Statements

You can iterate anything, set up a Conditional expression, and then utilize the BREAK and CONTINUE statements.

The way to do this is by doing a normal Conditional expression and using the mapping `#{break}` or `#{continue}` inside it. 

##### **Sample Code**

```
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}

 
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, Xporter for Jira 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.
```

---

# Sorting Iterations

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:

|  |
| --- |
| #{for comments|sortby=<Iteration mapping>} |

> ℹ️ The mapping after the `sortby` must be equal to the supported mappings for each Iteration.

**Example**

##### **Sample Code**

```
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}
```

#### Sort By Bulk Export

The `sortby` can also be used to sort a `&{for issues}` iteration on a Bulk Export.

##### **Sample Code**

```
&{for issues|sortby=IssueTypeName}
${Key} - ${IssueTypeName}
&{end}
```

> ℹ️ **Sorting Criteria**
> ℹ️ 
> ℹ️ `asc`** **and `desc`** **can be defined in order to define how you want to sort your data. The default value is `asc`

<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/XRAYCLOUD/pages/44577312).
</details>