×

Please give details of the problem

Skip to content

Loop

How to make a loop

Now let's try to make a loop over an array to create a new variable 'list_firstnames' containing firstnames.

We'll write in the script windows :

1
2
3
4
5
6
7
<#assign list_firstnames = "">

<#list my_array as x>
 <#assign list_firstnames = list_firstnames + " " + x.firstname>
<!--#list-->

${list_firstnames}

Note1 : first I create an empty variable 'list_firstname', then i make the loop to extract the data I want.
Note2 : x is the current element of my array. Will be my_array[0] the first time, then my_array[1] the second time etc....