---
title: "Exercise 1 - Populating the Comments from an Issue"
canonical: "https://docs.getxporter.app/space/XPORTERCLOUD/559830/Exercise%201%20-%20Populating%20the%20Comments%20from%20an%20Issue"
format: markdown
---
> Macro (rw-ui-expands-macro)
> 
> > Macro (rw-expand)
> 
> > Macro (toc)

# Introduction

The main goal of this exercise is to give you an idea about how [Xporter](https://marketplace.atlassian.com/apps/891368/xporter-export-issues-from-jira?tab=overview&hosting=cloud) works with [iterations](https://docs.getxporter.app/space/XPORTERCLOUD/428318/Iterations).

You'll learn how to populate the Issue Comments on an Xporter-generated file. The mappings in use are documented [here](https://docs.getxporter.app/space/XPORTERCLOUD/558575/Mappings).

# Populating the Comments from an Issue

> Macro (rw-ui-steps-macro)
> 
> > Macro (rw-step)
> 
> The section between `#{for comments}` and `#{end}` will grow dynamically according to the number of existing Comments on the Jira Issue.
> 
> > Macro (rw-step)
> 
> To start iterating over Issue Comments, put the mapping `#{for comments}` <span style="color: #333333">at the beginning of the iteration section of your </span>[<span style="color: #333333">Template</span>](https://docs.getxporter.app/space/XPORTERCLOUD/427622), and at the end, put the mapping `#{end}` to close it.
> 
> > Macro (rw-step)
> 
> Put `Comments[n].` at the beginning of the mapping of the Comment Field you're trying to populate. 
> 
> > Macro (rw-step)
> 
> When using the `#{for comments}` statement, the variable name will always be `n`**.** If you want to use a different variable name, like `a`, you must start your iteration instead with the statement `#{for a=CommentsCount}` (make sure to change it properly on the `Comments[``a``]. `at the beginning of the mapping of the Comment Field you're trying to populate):
> 
> ```
> #{for comments}
>    ${Comments[n].Author}
>    ${Comments[n].AuthorFullName} 
>    ${Comments[n].Body}
>    ${Comments[n].Created}
>    ${Comments[n].GroupLevel}
> #{end}
>  
> #{for <VariableName>=CommentsCount}
>    ${Comments[VariableName].Author}
>    ${Comments[VariableName].AuthorFullName} 
>    ${Comments[VariableName].Body}
>    ${Comments[VariableName].Created}
>    ${Comments[VariableName].GroupLevel}
> #{end}
> ```
> 
> > Macro (rw-step)
> 
> If you want to display your Comments Iteration as a table with a header, first create the header using a table with six columns and one row:
> 
> | **Author** | **Author Full Name** | **Body** | **Created date** | **Created date time** | **Group Level** |
> | --- | --- | --- | --- | --- | --- |
> 
> Below it, put the `#{for comments}` or `#{for <VariableName>=CommentsCount}` statement, so the header is printed only once.
> 
> > Macro (rw-step)
> 
> Then, create another table where the Issue Comments will be populated:
> 
> |  |  |  |  |  |  |
> | --- | --- | --- | --- | --- | --- |
> | ${Comments[n].Author} | ${Comments[n].AuthorFullName} | ${Comments[n].Body} | ${dateformat("dd-MM-yyyy"):Comments[n].Created} | ${dateformat("dd-MM-yyyy HH:mm:ss"):Comments[n].Created} | ${Comments[n].GroupLevel} |
> 
> > Macro (rw-step)
> 
> Close the statement using the mapping `#{end}`
> 
> > ℹ️ You can apply this to other types of [Iterations](https://docs.getxporter.app/space/XPORTERCLOUD/428318/Iterations).
> 
> ## Examples
> 
> Below (Figure 1) is a sample of how the mappings will be displayed in a Word template.
> 
> ![Figure 1 - Word template](media://1b6e05c6-649b-4dec-a3b3-718813a9132e)
> 
> This Template (Figure 1) includes:
> 
> - A header with a logo (Figure 1 - 1).
> - Headings (Figure 1 - 2).
> - Text styling (Figure 1 - 3).
> - A table (Figure 1 - 4).
> 
> Below (Figure 2) is a sample of how the generated file will be populated.
> 
> ![Figure 2 - Populated file](media://8fc25c62-166f-440a-9ea2-86c3cc5e7358)


> ℹ️ **This exercise is now complete. Proceed to **[**Exercise **](#)[**2**](#)** to learn h****ow to populate the links of your Issue and print a message when there's none.**
> ℹ️ 
> ℹ️ If you like this exercise, please leave a comment or a 👍. Your feedback is very important to us.
> ℹ️ 
> ℹ️ Thank you in advance. Enjoy our product!

<details>
<summary>Exercise 1 Resources</summary>

| **File** | **Description** |
| --- | --- |
|  | **Exercise 1 -** Sample Template file |
|  | **Exercise 1 -** Sample generated file |
</details>


<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://docs.getxporter.app/space/XPORTERCLOUD/18251779/In-App+Chat+Support).
</details>