What is a for-each loop in a Hoowla Document?

A for-each loop is a special tag in a Hoowla document that allows you to repeat a section of the document or letter for the number of people in the case e.g. for each client, print out their name.

Adding a for-each loop to a document

Like our custom fields (merge fields) that add your database data into letters, for-each elements are adding to the document with a combinations of [ ] and @@ symbols.

The for-each loop is assigned an entity (what is an entity?), which it repeats for the number of people you have assigned to the missing people section of Hoowla.  For example, if you use a for-each for a place for clients to put a signature and there are two clients in the case, the for-each will give a signature space for each client, as shown below.

 

 

To get the entity ID go to https://app.hoowla.com/app/setup-entities

Where you want the for-each loop to be displayed in a document copy the following code in, replacing ‘ENTITY_ID’ with the relevant ID:

[foreach entity=ENTITY_ID] add your document text here [/foreach]

 

For the example given above of space for the clients to sign the code would look like this:

[foreach entity=3240]

Client name: @client-full-name@

Clients Signature ____________________________

[/foreach]

You only need to enter this once and it will display the client names and signature spaces for the number of clients in the client people section in the case.  If you are unsure how to assign a person to a case see Assign Missing People.

 

Below is a short video showing how the for-each works and how to add the shortcode to a document.

For-each + separator

Sometimes you will want to put a word such as ‘and’ in between the loops of the information.

For example, you want to write out the clients name as ‘Josephine and Johnathan’.

To do this you add a section called [separator] and if you want that separator not to repeat at the end of the list of people, like in our example, you include the word ‘end’ in the [ ].  (If you don’t include the ‘end’ it would read ‘Josephine and Jonathan and‘.)

[foreach entity=ENTITY_ID]add your document text here [separator end]and [/separator] [/foreach]

So for our example above of Josephine and Jonathan you would add:

[foreach entity=3240]@client-full-name-no-title@ [separator end]and [/separator] [/foreach]

 

This then fills the information into the letter as below

 

Why would you want to add a for-each to a document

These for-each loops are ideal for a number of obviously scenarios, but their use is unlimited.  A number of ways they could be used are as follows:

Adding in a sentence ‘My clients John and Jayne Smith’.

Automatically adding a signature line to a letter for each client.

Automatically adding the right number of client boxes to a client questionnaire and digital information capture.

Automatically creating creditor reports for the number of creditors.

Automatically writing wills e.g. for each executor or beneficiary

If you would like help with using or implementing for-each loops please email us at support@hoowla.com or call 01792 687146