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 FieldsDescription
Author

The author of the comment

AuthorFullNameThe full name of the author of the comment
BodyThe comment
CreatedThe date the comment was posted
GroupLevelThe group level of the comment
Expand to see the 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}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue comments.

 Iterations_Comments.docx

 Iterations_Comments.xlsx


Iterating Issue Worklogs

Because it is not known in advance how many work logs 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 of 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
Expand to see the 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}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue worklogs.

Iterations_Worklogs.docx

Iterations_Worklogs.xlsx


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:

Components FieldsDescription
NameThe name of the component
DescriptionThe description of the component
LeadThe name of the component lead
IdThe ID of the component
ProjectIdThe project ID of the component
AssigneeTypeThe assignee type of the component
Expand to see the sample code
#{for components}
   ${Components[n].Name}
   ${Components[n].Description}
   ${fullname:Components[n].Lead}
   ${Components[n].Id}
   ${Components[n].ProjectId}
   ${Components[n].AssigneeType}
#{end}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue components.

Iterating_Issue_Components.docx

Iterating_Issue_Components.xlsx


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:

Status Transitions FieldsDescription
AuthorThe author of the status transition
CreatedThe date the status transition was performed
OldStatusThe old status of the status transition
NewStatusThe new status of the status transition
Expand to see the 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}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue status transitions.

Iterations_StatusTransitions.docx

 Iterations_StatusTransitions.xlsx


Iterating Issue Attached Images

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:

Attachments Images FieldsDescription
IDThe ID of the attached image
ImageThe image of the attached image
NameThe name of the attached image
SizeThe size of the attached image
HumanReadableSizeThe size of the attached image
AuthorThe author of the attached image
CreatedThe date the attached image was created
MimeTypeThe type of the attached image
ThumbnailURLThe image thumbnail URL.
Expand to see the 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}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue attached images.

Iterations_AttachedImages.docx

Iterations_AttachedImages.xlsx

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.

You can use the mappings "width" and "height" to define the exact width and height of the printed image.

Expand to see the sample code
#{for images}
   ${Images[n].Image|width=150|height=150}
 #{end}

These values are in pixels and if you only define one of them the image will be rescaled.

Note that, if you use both 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:

Attachments FieldsDescription
IDThe ID of the attachment
NameThe name of the attachment
AuthorThe author of the attachment
AuthorFullNameThe full name of the author of the attachment
CreatedThe date the attachment was created
SizeThe size of the attachment
HumanReadableSizeThe formatted size of the attachment
MimeTypeThe type of attachment
Expand to see the 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}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue attachments.

Iterations_Attachments.docx

Iterations_Attachments.xlsx


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:

Attachments FieldsDescription
NameThe name of the label
#{for labels}
   ${Labels[n].Name}
#{end}
 
or
 
#{for <VariableName>=LabelsCount}
  ${Labels[VariableName].Name}
#{end}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue comments.

Iterations_Labels.docx

Iterations_Labels.xlsx


Iterating Fix Versions of an Issue

You can iterate over all fix versions to which the issue belong to. The notation is:

Versions FieldsDescription
NameThe version name
DescriptionThe version description
Start dateStarting date of the version
Release dateRelease date of the version
ArchivedBoolean that indicates if the version is archived or not
ReleasedBoolean that indicates if the version is released or not
Expand to see the smaple 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}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue fix versions.

Iterating_Issue_FixVersions.docx

Iterating_Issue_FixVersions.xlsx


Iterating Affected Versions of an Issue

You can iterate over all affected versions to which the issue belong to. The notation is:

Versions FieldsDescription
NameThe version name
DescriptionThe version description
Start dateStarting date of the version
Release dateRelease date of the version
ArchivedBoolean that indicates if the version is archived or not
ReleasedBoolean that indicates if the version is released or not
Expand to see the 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}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue affected versions.

Iterating_Issue_AffectedVersions.docx

Iterating_Issue_AffectedVersions.xlsx


Iterating Project Versions

You can iterate over all project versions to which the issue belong to. The notation is:


Project Versions FieldsDescription
NameThe version name
DescriptionThe version description
Start dateStarting date of the version
Release dateRelease date of the version
ArchivedBoolean that indicates if the version is archived or not
ReleasedBoolean that indicates if the version is released or not
Expand to see the 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}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue project versions.

Iterations_ProjectVersions.docx

Iterations_ProjectVersions.xlsx


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 FieldsDescription
LinkTypeThe type of the link
KeyThe key of the linked issue
SummaryThe summary of the linked issue
URL

The URL of the link

Expand to see the 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}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue links.

Iterations_Links.docx

Iterations_Links.xlsx


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:

Subtasks FieldsDescription
KeyThe key of the subtasks
SummaryThe summary of the subtasks
AssigneeUserDisplayNameThe assignee user of the subtasks
Expand to see the 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}

The documents below demonstrate examples both in Word and Excel template that iterates over all the issue subtasks.

Iterations_Subtasks.docx

Iterations_Subtasks.docx


Iterating Issues In Epic

All fields listed here are available on IssuesInEpic[n] because they represent an issue.

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:

Expand to see the 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 template that iterates over the issues in epic.

Iterating_Issues_In_Epic.docx

Iterating_Issues_In_Epic.xlsx


Iterating Project Components

You can iterate over all project components. The notation is:

Expand to see the 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 template that iterates over the project components.

Iterating_Issue_ProjectComponents.docx

Iterating_Issue_ProjectComponents.xlsx


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:

Expand to see the sample code
#{for <VariableName>=<LinksCount|SubtasksCount|CommentsCount|WorklogsCount>|filter=%{<Javascript>}}
   Content here
#{end}
  • VariableName is the name of the variable to use as the iteration index.
  • LinksCount|SubtasksCount|CommentsCount  indicates over which type of entities you want to iterate.

  • Filter indicates the filter to be applied in the iteration.

Notice that as the filter is evaluated as a JavaScript expression, which provides flexibility in the definition of the conditions. You can use and (&&), or (||) and other logical operators supported by the JavaScript language.

It is also possible to format fields inside iteration filters.

The documents below demonstrate examples of a templates that iterate over issue links and comments with filters being applied.

Links Bugs with High Priority:

Links_with_Filter.docx

Links_with_Filter.xlsx

Nested Iterations:

Links_with_nested_Iterations.docx

Links_with_nested_Iterations.xlsx

For a working example of this functionality, check the template Sample Iterations in the Template Store.


Iterating in the same line of the document

You can also possible to 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. 

Expand to see the 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.

Expand to see the 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 statement

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. 

Expand to see the 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}
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 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, 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>}

NOTE: The mapping after the "sortby" must be equal to the supported mappings for each Iteration.

Example:

Expand to see the 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.

Expand to see the sample code
&{for issues|sortby=IssueTypeName}
${Key} - ${IssueTypeName}
&{end}

Sorting Criteria

asc and desc can be defined in order to define how do you want to sort your data. The default value is asc.



  • No labels