Reference Data

Add dynamic data inside an input of a block, like in the element selector or the form value input.

Accessing Data

Automa uses the mustache tag ({{ mustache }}) syntax to know which input is dynamic or not. Inside the mustache tag, you can either write the keyword of data you want to get from or a function, for example {{ keyword }}.

There're several sources of data that you can use:

keyworddescription
tableGet data from the table
variablesGet data from the variables
loopDataGet the current iteration data from the loop data block
prevBlockDataGet the data of the previous block
globalDataGet the global data of the workflow
googleSheetsGet the google sheets data
activeTabUrlGet the active tab url
workflowGet the data (table, global data, and google sheets) of the workflow that have been execute by the execute workflow block

You can replace the keyword with one of the above data sources, like {{ globalData }} or {{ table }}. The mustache tag will be replaced with the data from the keyword that you specify.

But, what if I have an object or array data type and want to get the specific property or index of the object or array? To do that, use the {{ keyword@path }} syntax and replace the path with the dot notation of the object or array. For example, when you input global data as an object:

{
  "firstname": "Amina",
  "lastname": "Ferry",
  "phone": 2347613906692,
  "gender": "female",
  "hobbies": ["cooking", "hiking", "camping"],
  "address": {
    "street": "540 Harris Track Suite 904",
    "streetName": "Edd Alley",
    "buildingNumber": "1135",
    "city": "North Kayleigh",
    "zipcode": "75882-2791",
    "country": "Guadeloupe"
  }
}
  • Get value of the firstName property.
    syntax: {{ globalData@firstName }}
    output: Amina

  • Get value of the phone property.
    syntax: {{ globalData@phone }}
    output: 2347613906692

  • Get the value of the street property of the address object.
    syntax: {{ globalData@adress.street }}
    output: 540 Harris Track Suite 904

  • Get the hobbies values.
    syntax: {{ globalData@hobbies }}
    output: ["cooking", "hiking", "camping"]

  • Get the first index value of the hobbies array.
    syntax: {{ globalData@hobbies.0 }}
    output: cooking

  • Get the second index value of the hobbies array.
    syntax: {{ globalData@hobbies.1 }}
    output: hiking

Functions

Inside the mustache tag, you also can call a built-in function that Automa has provided. Function name always starts with a dollar sign ($), for example {{ $func() }}. And here are some of the functions that available inside the mustache tag.

$date(date, dateFormat?)

Get or format a date. This function takes two parameters, which the second parameter is optional.

If you want to format the current date, you can directly pass the dateFormat as the first parameter, like {{ $date('DD-MMMM-YYYY') }}, and the output would be 14-January-2022. See all the available date formats on the day.js pageopen in new window.

And for the date parameter, see the valid date format on the MDN pageopen in new window.

Examples

$date("DD MMMM YYYY") // 14 January 2022
$date("DD-MM-YYYY, hh:mm A")  // 14-01-2022, 02:24 PM
$date("relative") // A few seconds ago
$date("timestamp") // 1651118110948

$date("2005-06-07", "DD MMMM YYYY") // 07 June 2005
$date("1977-04-01T14:00:30", "DD-MM-YYYY, hh:mm A")  // 01-04-1977, 02:00 PM
$date("14 January 2021", "relative") // A year ago
$date("14 January 2021", "timestamp") // 1610553600000

$randint(min?, max?)

Generate a random number. You can change the range of the random number by inputting the min and max parameters.

Examples

$randint() // 30
$randint() // 14

$randint(0, 10) // 4
$randint(0, 10) // 7

$getLength(str)

Get the length of a string or array.

Examples

// Get the length of a string
$getLength("testing") // 7

// Get tabel length
$getLength([table]) // 14

// Get the length of the "text" column on the second row
$getLength([table@1.text]) // 5

$randData(expression)

A function to generate random data, you only need to pass an expression to its parameter. For example, $randData("?l") will generate a random lowercase letter like a. Supported expression:

  • ?l: lowercase
  • ?u: uppercase
  • ?d: digit
  • ?f: uppercase + lowercase
  • ?s: symbol
  • ?m: uppercase + digit
  • ?n: lowercase + digit
  • ?a: any

You can also combine these expressions like $randData("?u?l?l?l?l?d?d@gmail.com") which will generate Apond89@gmail.com.

Examples

$randData("?d?d") // 89

$randData("?l?l?l?d?d@gmail.com") // wal29@gmail.com

$randData("?d?u?s?l?l?s?a?m") // 4C%ee^MF9

$multiply(value, multiplyBy)

Is used to multiply a value.

Examples

$multiply(5, 2) // 10

// Multiply a variable
$multiply([variables@variableName], 0.3) //20.7

$increment(value, incrementBy)

Is used to increment a value.

Examples

$increment(10, 2) // 12

$increment(72, 2) // 74

$divide(value, incrementBy)

Is used to divide a value.

Examples

$divide(22, 7) // 3.142857142857143

$divide(10, 2) // 5

$subtract(value, incrementBy)

Is used to subtract a value.

Examples

$subtract(80, 7) // 73

$subtract(11, 2) // 9

$replace(value, search, replace)

Is used to replace a string search from value to be replace string.

Examples

$replace("hello world!", "world", "everyone") // hello everyone!

$replace("hello world!", "hello", "hi") // hi world!

$toLowerCase(value)

Is used to lowercase a value.

Examples

$toLowerCase("HELLO WORLD!") // hello world!

$toLowerCase("hELLO wORLD!") // hello world!

$toUpperCase(value)

Is used to uppercase a value.

Examples

$toUpperCase("hello world!") // HELLO WORLD!

$toUpperCase("hELLO wORLD!") // HELLO WORLD!

$modulo(num, divisor)

Returns the remainder or signed remainder of a division.

Examples

$modulo(13, 5) // 3

$modulo(-13, 5) // -3

$modulo(4, 2) // 0

$modulo(-4, 2) // -0

Referencing Data Inside Mustache Tag

By using the square bracket([]), you can reference other data inside a mustache tag. For example, to format date based on the global data value {{ $date([globalData]) }}. Or if you want to get the table row based on the index of a loop {{ table@[loopData@loopId.$index].path }}.