Advanced Loops

Odette Chan
Odette Chan Athennian DocAuto Team Document Coding - Level 3
  • Updated

Now that we know the basics of looping through a collection, there are different ways we can bring this knowledge to a whole new level in our coding.

Nested Loops

Terminology

A collection is a category of data that is stored in Athennian. The highest level of each category is referred to as the root collection, as it's the broadest group of data. In order to keep the data structured neatly and organized logically, there are often sub-categories within those broader collections, which are called sub-collections

Screen

Syntax

In order to access a sub-collection's data, we would have to open it as we would normally access any collection.

{#rootCollection}{#subCollection}{subVariable}{/}{/}

Tables

Sample Root Collection Sample Sub-Collection
{#affiliations} {#addresses}
1

Aaron Arboretum

elected August 23, 2006

4373 Oakwood Drive, Meadow Lake SK (Residential)

2

Brittany Botany

elected March 20, 2020

105 Mossy Glen Lane, Pine Bluff AK (Delivery)

3

Carlos Chlorophyll

elected May 6, 2017

PH10 - 762 Whispering Pines Path, Thistle UT (Residential)
4

Daniel Deciduous

elected June 1, 2001

661 Cedar Ridge Court, Springfield IL (Business)
5

Everett Evergreen

elected November 5, 2012

Unit 3B - 4457 Redwood Avenue, Collingwood ON (Mailing)

Input

Name Address Start Date
{#affiliations}{participant_fullName} {#addresses}{address}{/} {startDate | time}{/}

Output

Name Address Start Date
Aaron Arboretum 4373 Oakwood Drive, Meadow Lake SK 2006-08-23
Brittany Botany 105 Mossy Glen Lane, Pine Bluff AK 2020-03-20
Carlos Chlorophyll PH10 - 762 Whispering Pines Path, Thistle UT 2017-05-06
Daniel Deciduous 661 Cedar Ridge Court, Springfield IL 2001-06-01
Everett Evergreen Unit 3B - 4457 Redwood Avenue, Collingwood ON 2012-11-05

Looping Page Breaks

There are two main ways to code documents where each loop begins on a new page.

Sample Shareholdings Data

Fiona Forrest holds 100 Common shares

Gemma Germinate holds 50 Common shares

Herbert Horticulture holds 100 Common shares

Isabella Iridescence holds 25 Common shares

Julian Juniper holds 10 Common shares

Microsoft Word Page Break Function

Since all content that appear between the {#} opening and {/} closing tags are included in each collection loop, by adding the page break function before the {/} closing tag, each loop will begin on the next page. 

Input

Screen

Output

MSpageBreak2.png

There is one problem with this method: it leaves a blank page at the end of the collection loop, which is necessary as the page in the template document that contains the {/} closing tag. If the document is a package that contains other documents that can begin on that last blank page, then it all works out and you may proceed to code using the native page break in Microsoft. But what if there isn't?

{@$pageBreakExceptLast}

By using this code {@$pageBreakExceptLast} in place of the Microsoft page break function, Athennian will be able to recognize that each new instance of the loop should begin on its own page, except the last loop. This removes the extraneous page that appears at the end of the generate document. 

Input

pageBreakEL1.png

Output

pageBreakEL2.png

Related to