If Last

Showing the last row in a collection

As well as the method here:

Arrays of data

It is possible to show the first/last item in a collection using in section rules.

We’d recommend you do it this way because unlike the earlier method this one allows you to select multiple items from the first/last row of a collection in a simpler way.

I.e. if we want to show the last row containing the four fields above we use:

#if @last

To illustrate this:

{{#each TransactionDetail.Payments}}

{{#if @last}}

{{PostedDate}} - {{TransAmount}} - {{TransDescription}} - {{Reference}}

{{/if}}

{{/each}}

I.e. in the above it is saying find the rows available in the collection of payments. Find the last row and for this show the 4 fields of posted date, transaction amount, transaction description and reference.

If it was the first row it would be:

{{#each TransactionDetail.Payments}}

{{#if @first}}

{{PostedDate}} - {{TransAmount}} - {{TransDescription}} - {{Reference}}

{{/if}}{{/each}}

Last updated

Was this helpful?