Action Loop
The Action Loop action allows you to run actions several times in a loop
NOTE: Loop actions are available in the Enterprise Edition only.
When would you use an Action Loop?
- When you need to split a string of email addresses and send an email to each one individually
- When you need to update or review each line item in a Record
- When you need to move Documents out of the current Record based on Category or SubCategory names
- Many more examples...
An action loop is simple a set of actions that are run over and over as many times as you tell it to run. Use the "Advanced" tab in the action to specify the number of times to run. Sometimes you know that ahead of time and sometimes you don't. If you don't then you can usually set up the system to find out for you using a variable. Inside the loop you can tell which loop number you are on by using the [LOOPACTIONCTR] variable. The first loop this will return 1, the second it will return 2 and so on. Inside the action loop you can add as many actions as needed.
Working Example
Let's use the scenario of splitting a string to get a list of email addresses. For each one we want to email that user and then add a note to the Record that we emailed them.
The Record Field we will use will be "EmailAddresses" and the addresses will be divided by a semi-colon ;. Let's say we have this in the field: "test@test.com;test2@test.com;test3@test.com" for 3 email addresses
In the "Advanced" tab of the Action Loop set the "Number of times..." setting to the string below. This will count how many email addresses are in that field when split by semi-colon. In our case it will return 3 so the loop will run 3 times.
[NUMELS([EmailAddresses]|;)]
Add an Email action inside the loop and set the TO address to the string below. This will split the string by semi-colon and return the element that is at the [LOOPACTIONCTR] position. That starts at 1 and so on. Then add something to the body just in case.
[SPLIT([EmailAddresses]|;|[LOOPACTIONCTR])]
Add a Record Note action inside the loop and set the note text to the string below. This will use the same split value as the email one to add to the note.
Emailed: [SPLIT([EmailAddresses]|;|[LOOPACTIONCTR])]
When you run this example it should email 3 times and have 3 notes in the active Record.
There are MANY uses for the Action Loop. Just remember to use the [LOOPACTIONCTR] variable to point to the right data. If you are using this with Line Items then you can use that variable in the Line Item field in most actions like the Record Variable Update or Create Record actions.