Repeating Blocks

<< Click to Display Table of Contents >>

Navigation:  Message Triggers > Extracting Fields >

Repeating Blocks

Often messages contain repeating sections. Most of the time you need to run a process or update a database for each individual section of the repeating section. ThinkAutomation allows you to do this by defining a field as a 'repeating block'. When a field is defined as a repeating block, ThinkAutomation will enter a loop and extract each block of the repeating section in turn. This is then used in conjunction with the 'pass to' trigger option - allowing you to pass the individual blocks to another trigger for processing.

 

For example:

 

Suppose you receive the following email:

 

Name: Stephen

Company: PSL

Order Ref: 1234

 

Product: WHO1

Qty: 1

 

Product: WHO2

Qty: 2

 

The Product and Qty fields can repeat any number of times depending on what the customer has ordered.

 

We can define the Product & Qty fields as a single field and set them as a repeating block. The repeating block can then be passed to another trigger for processing on it's own.

 

We would define the extraction of the above fields as follows:

 

triggerfields_block

 

The Name, Company and Order fields we extract by looking for the Name:, Company: and Order Ref: field headers and extracting until the end of the line.

 

For the Block field we set the Look For to '*' - which means start from the next character after the last extract point:

 

Resources_Images_blockexample2

 

We set the Extract Data option to Until These Characters - and set this to <CRLF><CRLF>. This basically means 'the next blank line'.

 

Resources_Images_blockexample3

 

You then enable the 'Is Repeating Block' option on this field. ThinkAutomation will then repeat the field extraction until it either finds the next field in the extracted fields list or the end of the message.

 

We then create another Trigger. In this case - called 'Order Lines'. This trigger will receive each section of the repeating block as a new message. This trigger can extract the Product and Qty fields and perform further processing and update a database which each product ordered.

 

On the 'Pass To' tab of the repeating block field we select this new trigger:

 

Resources_Images_blockexample4

 

In the Set Body Text To field we also pass the Order Ref: extracted field. This allows us to use this value in addition to the block section in our 'pass to' trigger.

 

The Order Lines pass to trigger would receive 2 messages in the above example. The messages would be:

 

Order Ref: 1234

Product: WHO1

Qty: 1

 

and then

 

Order Ref: 1234

Product: WHO2

Qty: 2

 

 

 

 

 

 

ThinkAutomation © Parker Software 2016