GoLess
  • Basics
    • Recording Actions
    • Adding workflow manually
    • Tutorial: Scraping data
  • Workflow
    • Customization
    • Blocks
    • Global Data
    • Variables
    • Element Selector
    • Expressions
    • Workflow Table
    • Looping
    • Google Drive
  • Blocks
    • General
      • Note Block
      • Trigger Block
      • Execute Workflow Block
      • Delay Block
      • Export Data Block
      • HTTP Request Block
      • Blocks Group
      • Clipboard Block
      • Wait Connections Block
      • Notification Block
      • Workflow State
      • Parameter Prompt Block
    • Browser
      • Active Tab Block
      • New Tab Block
      • Switch Tab Block
      • New Window Block
      • Proxy Block
      • Go Back Block
      • Go Forward Block
      • Close Tab/Window Block
      • Take Screenshot Block
      • Browser Event Block
      • Handle Download Block
      • Handle Dialog Block
      • Reload Tab Block
      • Get Tab URL Block
      • Cookie Block
    • Web Interaction
      • Click Element Block
      • Get Text Block
      • Scroll Element Block
      • Link Block
      • Attribute Value Block
      • Forms Block
      • Javascript Code Block
      • Trigger Event Block
      • Switch Frame Block
      • Upload File Block
      • Hover Element Block
      • Save Assets Block
      • Press Key Block
      • Create Element Block
    • Control Flow
      • Repeat Task Block
      • Conditions Block
      • Element Exists Block
      • While Loop Block
      • Loop Data Block
      • Loop Elements Block
      • Loop Breakpoint
    • Data
      • Insert Data Block
      • Delete Data Block
      • Get Log Data Block
      • Slice Variable Block
      • Increase Variable Block
      • RegEx Variable Block
      • Data Mapping Block
      • Sort Data Block
    • Оnline Services
      • Google Sheets Block
    • Premium
      • ChatGPT Block
      • Captcha Block
  • REFERENCE
    • Logs
    • Schedule
    • Storage
    • Packages
    • Condition Builder
    • Workflow Common Errors
    • JavaScript Execution Context
Powered by GitBook
On this page
  • Writing Expression
  • Access Another Data Inside the Expressions
  • Functions
  • $date(date, dateFormat?)
  • $randint(min?, max?)
  • $getLength(str)
  • $randData(expression)
  • $multiply(value, multiplyBy)
  • $increment(value, incrementBy)
  • $divide(value, incrementBy)
  • $subtract(value, incrementBy)
  • $replace(value, search, replace)
  • $replaceAll(value, search, replace)
  • $toLowerCase(value)
  • $toUpperCase(value)
  • $modulo(num, divisor)
  • $filter(data, syntax)
  • $stringify(value)
  • Examples
  • Table
  • Variables
  • JavaScript Expressions
  1. Workflow

Expressions

PreviousElement SelectorNextWorkflow Table

Last updated 1 year ago

With this feature, you can define a dynamic value for a block based on the data from:

Title
Description
Access item

table

Retrive data from the Table

table

variables

Retrive data from the Variables

variables.<variableName>

loopData

Retrive the current iteration data of the Loop Data block

loopData.<loopId>

prevBlockData

Retrive the data of the previous block

prevBlockData

globalData

Retrive the global data of the workflow

globalData

googleSheets

Retrive the Google Sheets data

googleSheets.<referenceKey>

activeTabUrl

Retrive the active tab url

activeTabUrl

workflow

Retrive the data (Table and Variables) of the workflow that have been run by the Execute Workflow block

workflow.<executeId>

GoLess uses a mustache templating model and expands it with data from overhead and functions.

Writing Expression

To write an expression, you should use the following format: "{{ keyword }}". Change the keyword with one of the data sources mentioned above. It helps GoLess distinguish static from dynamic data.

For example, assume that you have a variable named socials inside the workflow. Its value is an array of objects. You can use the HTTP Request block to send this variable to the API.

The following phrase can be used in the body of the HTTP Request block:

{{variables.socials}}
HTTP Request block body

If you want to use the url property on the first element of the array as a value inside the New Tab block URL, you can use the following expression:

{{variables.socials.0.url}}

The first element of the array here is expressed as 0. Use 1 for the 2nd element of the array, 2 for the 3rd element, 3 for the 4th element, etc.

Access Another Data Inside the Expressions

{{$increment([variables.variableName]}}

{{table.[loopData.loopId.$index].columnName}}

Functions

All built-in functions always begin with the prefix $, for instance, $funcName(param); here is a reference list of available functions in GoLess.

$date(date, dateFormat?)

This fuction gets or formats a date. It takes two parameters, the second parameter is optional.

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?)

Produces a random number. You can set up the range of the random number by entering the min and max parameters.

Examples

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

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

$getLength(str)

Gets the length of an array or string.

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)

This function generates random data. Pass an expression to its parameter and it will generate something random. For instance, $randData("?l") will produce a random minuscule letter like a. Supported expressions:

  • ?l: lowercase

  • ?u: uppercase

  • ?d: number

  • ?f: uppercase + lowercase

  • ?s: symbol

  • ?m: uppercase + number

  • ?n: lowercase + number

  • ?a: any

You can also mix several expressions together. For example, $randData("[email protected]") will produce [email protected].

Examples

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

$randData("[email protected]") // [email protected]

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

$multiply(value, multiplyBy)

Multiplies a value.

Examples

$multiply(5, 2) // 10

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

$increment(value, incrementBy)

Increments a value.

Examples

$increment(10, 2) // 12

$increment(72, 2) // 74

$divide(value, incrementBy)

Divides a value.

Examples

$divide(22, 7) // 3.142857142857143

$divide(10, 2) // 5

$subtract(value, incrementBy)

Subtracts a value.

Examples

$subtract(80, 7) // 73

$subtract(11, 2) // 9

$replace(value, search, replace)

Replaces a search string from value with a replace string.

Examples

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

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

$replaceAll(value, search, replace)

Replaces all the matches string search from value with a replace string.

Examples

$replace("hello world!", "o", "0") // hell0 w0rld

$replace("The temperature is 25 degrees today", " ", "") // Thetemperatureis25degreestoday

$toLowerCase(value)

Converts value to a lowercase

Examples

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

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

$toUpperCase(value)

Converts value to a uppercase

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

$filter(data, syntax)

  • data: Javascript object to query

Examples

Querying colors variable with these as the value:

[
	{ color: "red", value: "#f00" },
	{ color: "green", value: "#0f0" },
	{ color: "blue", value: "#00f" },
	{ color: "cyan", value: "#0ff" },
	{ color: "magenta", value: "#f0f" },
	{ color: "yellow", value: "#ff0" },
	{ color: "black", value: "#000" }
]
{{ $filter([variables.colors], "$..color") }}
// ['red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'black']

{{ $filter([variables.colors], "$..value") }}
// ['#f00', '#0f0', '#00f', '#0ff', '#f0f', '#ff0', '#000']
!!{{ $filter(variables.colors, "$..color") }}
// ['red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'black']

!!{{ $filter(variables.colors, "$..value") }}
// ['#f00', '#0f0', '#00f', '#0ff', '#f0f', '#ff0', '#000']

$stringify(value)

Converts JavaScript value to a JSON string.

Examples

This section gives further examples of writing expressions and provides some information about the structure of the source data.

Table

The table is stored as an array of objects with the table column as the object key.

[
  { "color": "blue", "value": "#00f" },
  { "color": "cyan", "value": "#0ff" },
  { "color": "magenta", "value": "#f0f" },
  { "color": "yellow", "value": "#ff0" },
  { "color": "black", "value": "#000" }
]
  • Get the first row: expression: {{ table.0 }} output: { "color": "blue", "value": "#00f" }

  • Get the second row: expression: {{ table.1 }} output: { "color": "cyan", "value": "#0ff" }

  • Get the last row: expression: {{ table.$last }} output: { "color": "black", "value": "#000" }

  • Get value of the color column on the first row: expression: {{ table.0.color }} output: blue

  • Get value of the value column on the first row: expression: {{ table.0.value }} output: #00f

Variables

The variables are stored as an object with the variable title as the object key.

{
  "url": "https://goless.com",
  "numbers": [100, 500, 300, 200, 400]
}
  • Get the value of the url variable: expression: {{ variables.url }} output: https://goless.com

  • Get the value of the numbers variable: expression: {{ variables.numbers }} output: [100, 500, 300, 200, 400]

  • Get the first number of the numbers variable: expression: {{ variables.numbers.0 }} output: 100

JavaScript Expressions

::: Note: this is only supported in the browsers based on Google Chromium :::

With GoLess, you also use javascript within the expressions. To write a javascript, you must add !! symbols as the first value on a text field of a block. For instance, from The number is: {{variables.number}} to!!The number is: {{variables.number}}.

You can also use the integrated function like the javascript function.

Examples

  • Use of integrated functionality:

{{$getLength(table)}} //10

{{$randData("?d?d")}} // 89
  • Get the last row of the table:

{{table[table.length - 1].columnName}}
  • Get current timestamp:

{{Date.now()}} //1666237704022
  • Access loop data and index:

// Loop data
{{loopData.loopId.data}}

// Loop index
{{loopData.loopId.$index}}
New tab block URL

Wrap the expression with a bracket ([]) to access other data inside the expression. For instance, let's take the situation when you want to increment a variable using the function or get the table row based on the current index of the loop. In this case, you can write the expressions as follows:

Suppose you want to format the current date. In that case, you can pass the dateFormat straight as the first parameter. For example,{{ $date('DD-MMMM-YYYY') }}, and the output would be 14-January-2022. You can check all the available date formats on the .

Also, you can check the valid date format on the for the date parameter.

Filter/Query javascript object. GoLess uses the library to make a query.

syntax:

Using

JS Expression
$increment
day.js page
MDN page
JSONPath
JSONPath Syntax
JS Expressions