You are on the Xporter Server documentation. If you are looking for Xporter Cloud documentation, you can find it in this page.

In this exercise, you'll learn how to populate set functions while iterating issue attachments.

The function Set allows the creation of new variables that will be treated as fields (mappings) and change the values of those variables.

The notation to define a set function is:

${set(<variable name>,<new value>)}

You can check more details here.

First, create a set function count and in this case, initialize the value to zero.

${set(count,0)}

If you want to display your Attachments Iterations as a Table with a Header, first create the Header using a table with 3 columns and 1 row:

NameSizeTime

Below, put the #{for attachments} or #{for <VariableName>=AttachmentsCount} statement, so the Header is printed only once.

Then, redefine the variable count to increment by one. To do this, use the set function again, but using the previous count value with JavaScript.

${set(count,%{${count} + 1})}

With that done, create another table where the Issue attachments will be populated:

${Attachments[n].Name}${Attachments[n].HumanReadableSize}${dateformat("dd-MM-yyyy HH:mm:ss"):Attachments[n].Created}

To display the current iteration index, print the redefined variable using ${count}.

Finally, close the statement using the mapping #{end}.

You can do this on other types of Iterations.

You can check the iterations here.

Below is a sample of how the mappings will be displayed in a Word template:

This Template has:

  • A header with an image
  • Headings
  • Text styling
  • Table

Below is a sample of how the generated file will be populated:

If you like this exercise, please leave a comment or a (thumbs up). Your feedback is very important to us.

Thank you in advance.

Enjoy our product. (big grin)

Here are the files related to this Exercise:

FileDescription
Exercise5Template

Exercise 5 Sample Template file

Exercise5GeneratedExercise 5 Sample generated file
  • No labels