Skip to content

Lists, loops and data in a workflow

Concept8 minExpert

Before you start

While a workflowWorkflowAn automation: trigger plus steps, run per module; also called "flow" on the home page.Open glossary ↗ runs, it holds one record, the one that started it, and any number of named lists of other records. Every step can read what the workflow holds at that point. Knowing which of the two a step is reading is most of the skill.

  1. Load data
  2. List holds records
  3. Loop: each item
  4. Step reads the item
A workflow with a Trigger, a Record manager that updates Contracts, a Load data step named List that loads Vendors as vendorProfile, and a Send email step addressed to the primary contact email.
    The Record manager works on the record that started the workflow.
    Load data puts vendors into a list named vendorProfile.
    Send email reads that list. With no Loop, it reads the first vendor.
  • The record that started it. For a record trigger, this is the record that was saved, with its current values. For a scheduled workflow there is none.
  • A list from Load data. The step finds records of any module and keeps them under a name you choose.
  • A list from a JSON parser, a CSV parser or a Loop that counts. A JSON parser turns the body of a webhook or a text field into data. A CSV parser reads the rows of a file. A Loop that counts makes a list with one record whose field index is the round number.

Steps use data through the Insert data picker, which lists the record and every list the step can reach. Beezr writes the reference for you, as a token in the form $table$.$field$. Smart Script, the language behind Beezr’s scripts and conditions, reads the same tokens. See Smart Script.

A list is a set of records. A step that reads one field of it gets the value from the first record. The picker shows it as the list name, an arrow and the field, for example vendorProfile › Email.

Sort decides which record is first. Without a sort, records come oldest first. So choose a sort when you want the newest, the biggest or the nearest, and read the first record.

To use every record, add a Loop. In a round, the list’s name means the current record, and the steps inside the loop work on it. The picker shows it as Current item.

Repeat forRepeatsUse it to
Each record in a listOnce per record of a list made aboveEmail every vendor with an expired contract
Each item inside a fieldOnce per item of a List field on the current recordGo through the lines of an order
A number of timesN times, counting from 1Do the same thing a fixed number of times, such as creating 3 starter records

A loop has two paths on the canvas. Each item is the body. After loop is what continues when the rounds end. If a round fails, the workflow stops at that round. A Terminate inside the loop ends the whole workflow, not only the loop.

For a large set of records, switch on Process in pages on the Loop. It reads the list from the database one page at a time. The page size is 200 unless you set another, and Stop after sets when the loop ends.

A list lives while the workflow runs, on the path that made it.

  • After an Approval task, load the lists you need again. The workflow resumes with a fresh copy of the record.
  • After a loop over records, save what you need with a Record manager inside the loop. A loop that counts keeps its list.
  • On the same path. Make the list on the path that uses it, above the steps that read it.
  • Running a step again, for example inside a loop, refreshes its list.

To handle an empty list, add a Decision, pick the list itself, and choose the check has no records.

  • It sees every record in the module, whoever started the workflow. Record permissions do not apply.
  • You describe the records with rules, such as Status is Pending approval, or with a Smart Script written as a WHERE clause. See Load data.
  • Add at least one rule. To load every record, use the Smart Script tab with WHERE 1 = 1.

Check yourself

A Load data step loads 3 vendors into a list called vendorProfile. A Send email step later reads vendorProfile › Email, outside any loop. Which email address does it get?
Show the answer

The email of the first vendor in the list. Outside a loop, a step reads the first record of a list. Use a Loop to go through every record.

Nour wants a Load data step to load every record of a module. What does she write on the Smart Script tab?
Show the answer

WHERE 1 = 1. Add rules to choose the records. WHERE 1 = 1 matches every record.

A workflow loads invoices, then pauses for approval. Where should the list be loaded for a Loop after approval?
Show the answer

The list must be loaded again below the approval, because the workflow resumes with a fresh copy of the record. The workflow resumes with a fresh copy of the record. Load lists again below the approval.

What's next

Last checked