Writing expressions

In FL0, the text fields of a component’s settings accept JavaScript expressions. These expressions are evaluated at run-time and replaced with the result of the evaluation.

These are some examples of valid expressions:

  • 1 + 1
  • new Date(19, 07, 1990)
  • “HELLO WORLD”.toLowerCase()

You can use expressions to make flows more flexible and intelligent by calculating and manipulating values on the fly, rather than defining the values ahead of time.

Referring to steps and variables

When a text field of a component’s settings has focus, a dropdown appears. This dropdown contains a list of:

  • The flow’s steps and the data output by those steps
  • Variables available within the context of the flow

If you select one of the items in the list, the following syntax appears in the field:

Insert.data

This syntax is another example of an expression. At runtime, FL0 evaluates this expression and replaces it with a value from a previous step in the flow or the value of a variable.

Expressions that refer to steps are made up of two parts:

  • The name of the step or variable (e.g. Insert)
  • The name of a property output by the step or variable (e.g. data)

You can use standard JavaScript operators and methods to manipulate the output of steps and variables:

  • Insert.data.age > 30
  • Insert.data.name.toLowerCase() === "david"
  • new Date(2021,07,19).toUTCString()

Note: You don’t typically need to write expressions that refer to steps or variables from scratch, but you may modify them, so it can be useful to understand how to read them.

Accessing object properties

If the output of a step or a variable contains an object, you can use dot-notation to access the value of a specific property:

Insert.data.id

You can use chaining to access the values of nested properties:

Insert.data.user.id

Accessing array elements

If the output of a step or a variable contains an array, you can use an index to access the value of a specific element:

<array>[<index>]