Conditional Logic and Looping

Axiom contains many methods of looping through data and using conditional logic to alter control-flow.

# Loop Through Data

The Loop Through Data step is the most common method of looping.

This will execute a set of steps for every row of data passed as input.

For example, if 3 rows of a Google Sheet data are passed into input, axiom will loop 3 times.

This step is designed for executing a step of operations, using a data source.

Some examples of good use cases include:

  • Data entry from a Google Sheet
  • Scraping a list of links from a Google Sheet.

# Use If Conditions

Axiom's If condition uses a data source as an input. Based on evaluating the if condition, it will execute a subroutine of steps (or sub-steps).

The if condition gives 2 options for conditions to evaluate:

  • Matching words in the data source. For example, if the data contains the word 'Complete', execute these steps.
  • Any JavaScript expression that evaluates to true. Axiom data can be passed to this JavaScript expression. For using JavaScript in axiom, see: Write JavaScript (opens new window)

# Continue Only If A Condition Is True

Axiom's Continue only if a condition is met step, is similar to the If condition. Using data input, we can check for certain words, or apply a JavaScript rule to this data.

Instead of executing a subroutine, this step will either continue or stop the axiom execution. We can optionally set the axiom to fail, if this condition fails.

# Conditionally Jump To Another Step

Axiom's Conditionally jump to another step step, is similar to the If condition. Using data input, we can check for certain words, or apply a JavaScript rule to this data.

This step will jump to another step, if the condition passes. It is very similar to a 'Go To' statement in programming. This is a powerful step, but it can also be used to make complicated axioms that are difficult to understand.

By default, the 'Maximum cycles' is 20, to prevent infinite loops.

# Loop N times

If you would like to loop N times, create a Conditionally jump to another step step, set the 'Maximum cycles' to N.

# Catch Errors

Axiom contains several methods of handling errors, but perhaps the most useful is the Try / Catch step. See our guide on error handling

See: Try Catch (opens new window)