Skip to content

Expressions

Below are the expressions I can use in OmniLogin's Automation

Global Data

Global Data is data that can be used in your workflow. I can add data from a file into the global data

Example

First, I will input values into Global Data

setting node

Then open Google by node Open URL and use the expression {{globalData.0.key}} to retrieve the first value of the key key and use it in the Press Key node

setting node

Previous Block

Each time a block is executed

Example of outputting the value of the previous node using the Press Key node

First, I will open the google.com page using the Open URL node. Next, I will retrieve the value of the previous node and output it to the search bar of the page using the expression {{prevBlockData}} with the Press Key node right after the Open URL node. The value printed is the URL of the page I just opened.

setting node

Accessing Other Data Within an Expression

To access other data within an expression, you must wrap the expression for accessing data in brackets ([]). For example, you cannot use the expression {{globalData.{{variables.a}}}} but must write {{globalData.[variables.a]}}

Functions

All built-in functions always start with the prefix $; for example: $funcName(param). Here is a reference list of the functions available in Automation.

$date(date, dateFormat?)

Retrieves or formats a date. This function has two parameters, with the second one being optional.

If you want to format the current date, you can directly pass dateFormat as the first parameter, for example, {{ $date('dd-MMMM-yyyy') }}, and the result will be 14-September-2023. See all available date formats on this page.

For the date parameter, see valid date formats on the MDN page.

Example

I can use the date function in various ways as follows

setting node

setting node

With the above expression, I will display the following values

i

  • The value assigned to the variable a by the expression generates the current date with the format day/month/year/hour:minute AM/PM

  • The value assigned to the variable b by the expression generates the current date with the format day/month/year/hour:minute AM/PM timezone

  • The value assigned to the variable c by the expression generates the current date with the format day-month-year-hour:minute AM/PM

  • The value assigned to the variable d by the expression generates the current date with the format timestamp at the current moment

  • The value assigned to the variable e by the expression returns the desired format with the input time parameter

$rand(min?, max?)

This rand function generates a random number in the range from min to max (inclusive). If both min and max are integers, it returns a random integer in the range. If either min or max is not an integer, it returns a random decimal number in the range.

Example

I can use the function in cases like the following.

i

When running, I will see the variables receiving the following values

i

  • The value assigned to the variable a by the expression randomly generates a number in the range from 0 to 100

  • The value assigned to the variable b by the expression randomly generates a number in the range from 0 to 10

  • The value assigned to the variable c by the expression randomly generates a number in the range from 0 to 10.4, which will always produce a decimal digit

  • The value assigned to the variable d by the expression randomly generates a number in the range of the values of variables a to b

$randint(min?, max?)

This randint function generates a random integer in the range from min to max (inclusive). If min and max are not provided, it defaults to the range from 0 to 100.

Example

I can use the function in cases like the following.

i

When running, I will see the variables receiving the following values

i

  • The value assigned to the variable a by the expression randomly generates a number in the range from 0 to 100

  • The value assigned to the variable b by the expression randomly generates a number in the range from 0 to 10

  • The value assigned to the variable c by the expression randomly generates a number in the range from 0 to 10.4. Since it is a function that generates random integers, the result will be a positive integer

  • The value assigned to the variable d by the expression randomly generates a number in the range of the values of variables a to b

$getLength(str)

This function attempts to parse the input string str into JSON. If successful, it returns the length of the resulting value. If parsing fails (i.e., str is not valid JSON), it returns the original string str.

Example

I can use the function in cases like the following.

ii

When running, I will see the variables receiving the following values

i

  • The value assigned to the variable a by the expression calculates the length of a text string

  • The value assigned to the variable b by the expression calculates the length of a table

The length of the table is the number of elements in an array. As shown in the image, I have an array with 3 object elements, so the length result will be 3

i

  • The value assigned to the variable c by the expression calculates the length of the first data in the table

As shown in the image, the first element in the table is the object {"name":"john"}, and the value in the name column is john. The length of that string will result in 4 !

  • The value assigned to the variable e by the expression calculates the length of a variable containing a text string

$getOTP(secret)

This function takes a parameter as a string and then generates an OTP code based on that string. Typically, this function is used when I want to retrieve the 2FA code entered.

Example

I can use the function in cases like the following.

i

The result returned will be as follows

i

  • The value assigned to the variable a by the expression generates an OTP code based on an input string

  • The value assigned to the variable c by the expression generates an OTP code based on an input variable b

Note

I need to set the time on the machine to match the actual time to avoid errors with this function

$randData(text)

This randData function generates a random character or string based on the input text. If text is a string, it replaces any occurrence of a question mark (?) followed by a letter with a random character of the corresponding type (lowercase, uppercase, digit, special character, or a combination of these).

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

I can use the function in cases like the following.

i

The result returned will be as follows

i

  • The value assigned to the variable a by the expression generates a string consisting only of uppercase letters, lowercase letters, and digits

  • The value assigned to the variable b by the expression generates a string consisting only of lowercase letters and digits, then appends @gmail.com to randomly generate a Gmail address

  • The value assigned to the variable c by the expression generates a string consisting only of lowercase letters, digits, symbols, and any

$randDate(minDate?, maxDate?, dateFormat?)

The function generates a random timestamp within the range of two parameters minDate (starting from 01-01-1990) and maxDate in any display format of dateFormat. The default format is dd-MM-yyyy: 12-12-2000. If you want to change the format, you can add dateFormat after the time range.

Example

I can use the function in cases like the following.

i

The result returned will be as follows

i

  • The value assigned to the variable a by the expression randomly generates a time unit in the default format day-month-year

  • The value assigned to the variable b by the expression randomly generates a time unit in the format day/month/year

  • The value assigned to the variable c by the expression randomly generates a time unit in the format year/month/day

$randPick(data)

The function randomly selects one element from the data array data. This function is commonly used when you input an array into the function.

Example

I can use the function in cases like the following.

First, create an array with 3 elements

i

Then use the expression {{$randPick([variables.a])}} in the Write Log node to return a random element from the a array

i

The result returned will be as follows

i

$randChoice(...data)

This function is quite similar to the randPick function, as both select a random element from an array. However, this function allows you to directly add elements to the function for use. When values are added, it automatically converts them into an array and performs the action of selecting one random element. You typically use this function when you want to randomly select a value from a list within the function.

Example

I can use the function in cases like the following.

i

The result returned will be as follows

i

The value assigned to the variable a by the expression randomly selects an element from the input list of elements

$split(value, param)

This split function splits a string into an array of substrings based on a specified delimiter param. If no delimiter is provided, it defaults to a space. If the input value is not a string or is empty, the function returns the original value.

Common case example

Typically, I will use this function as follows splitsplit

The value after running will display as follows

split

  • The value assigned to the variable a by the expression converts the input string based on the delimiter " "

  • The value assigned to the variable c by the expression converts a variable with a string value based on the delimiter " "

  • The value assigned to the variable e by the expression converts a variable with a string value based on the delimiter " " assigned to the variable d

Example of splitting a string separated by line breaks

In the case where the input values are separated by line breaks split

In this case, I cannot use the expression as in the examples above. I need to create a variable and insert the line break value by pressing Enter in the variable’s value input field. Then use the split expression with the param value as the expression retrieving the delimiter variable value, which is variables.delimiter. The expression to split the string into an array will be as follows

split

The returned value will be an array containing the input values

split

$increment(value, incrementBy)

This function increases the value by adding a certain amount, but only if both the value and the increment are numbers. If either is not a number, the original value is returned.

Example

I will use this function in the following cases split

The returned value will be as follows

split

  • The value assigned to the variable a by the expression adds two numbers
  • The value assigned to the variable b by the expression adds a variable’s value to a number or vice versa
  • The value assigned to the variable c by the expression adds the values of two variables together

$subtract(value, incrementBy)

This function subtracts incrementBy from value if both are numbers; otherwise, it returns the original value of value.

Example

I will use this function in the following cases split

The returned values will be as follows

split

  • The value assigned to variable a is from an expression subtracting two numbers

  • The value assigned to variable b is from an expression subtracting a variable’s value from a number or vice versa

  • The value assigned to variable c is from an expression subtracting the values of two variables from each other

$increment(value, incrementBy)

This function increases the value by adding a certain amount, but only if both the value and the increment are numbers. If either is not a number, the original value is returned.

Example

I will use this function in the following cases split

The returned value will be as follows

split

  • The value assigned to the variable a by the expression adds two numbers
  • The value assigned to the variable b by the expression adds a variable’s value to a number or vice versa
  • The value assigned to the variable c by the expression adds the values of two variables together

$subtract(value, incrementBy)

This function subtracts subtractBy from value if both are numbers; otherwise, it returns the original value of value.

Example

I will use this function in the following cases split

The returned value will be as follows

split

  • The value assigned to the variable a by the expression subtracts two numbers
  • The value assigned to the variable b by the expression subtracts a variable’s value from a number or vice versa
  • The value assigned to the variable c by the expression subtracts the values of two variables from each other

$multiply(value, multiplyBy)

This function multiplies two values together, but only if both values are numbers. If either value is not a number, it returns the original value.

Example

I can use the function in cases like the following.

split

The result returned will be as follows

i

  • The value assigned to the variable a by the expression multiplies two numbers together
  • The value assigned to the variable a by the expression multiplies a variable’s value by a number
  • The value assigned to the variable a by the expression multiplies the values of two variables together

$divide(value, incrementBy)

This function divides value by divideBy and returns the result. However, if value or divideBy is not a number, it returns the original value instead of performing the division.

Example

I can use the function in cases like the following.

i

The result returned will be as follows

i

  • The value assigned to the variable a by the expression divides two numbers
  • The value assigned to the variable a by the expression divides a variable’s value by a number
  • The value assigned to the variable a by the expression divides the values of two variables

$slice(value, start, end)

The slice function extracts a portion of a string or array value and returns a string from start to end. The last element of the new string will be before the end position. For example, if I want to extract a string where the 5th element is a and the 6th is b up to the 6th element, it will only take the value a. Additionally, if only start is provided without end, the extracted string will run from start to the end of the string.

Example

I can use the function in cases like the following.

ii

  • The value assigned to the variable a by the expression slices the string Hello,world! from position 1 to 6
  • The value assigned to the variable c by the expression slices the variable b containing the string Hello,world! from position 1 to 6
  • The value assigned to the variable f by the expression slices the variable b containing the string Hello,world! based on the desired range inserted into the variables d as 1 and e as 6, so the slicing range will be from 1 to 6
  • The value assigned to the variable g by the expression slices the variable g containing the string hello every from the 2nd element position to the end of the string

The result returned will be as follows

ii

$replace(value, search, replace)

The function first converts all parameters to strings. If the search parameter is a regular expression (i.e., starts and ends with slashes /), it creates a new RegExp object and uses it to replace matching substrings in the value string. Otherwise, it performs a simple string replacement. If the value string is empty, the function returns it immediately without performing any replacement.

Example

I can use the function in cases like the following.

ii

  • The value assigned to the variable a by the expression replaces the string very in the text with the input string easy to use
  • The value assigned to the variable c by the expression replaces the substring great in the variable b containing the text OmniLogin very great with the input string awesome
  • The value assigned to the variable f by the expression replaces the substring great assigned to the variable d in a variable b containing the text OmniLogin very great with the string awesome assigned to the variable

The result returned will be as follows

i

$replaceAll(value, search, replace)

This replaceAll function replaces all occurrences of the search string or regular expression in the value string with the replace string. It first checks if the search string is a regular expression (starts and ends with /) and creates a RegExp object if true. Then, it uses the replaceAll method to replace all occurrences of the search string or regular expression with the replace string. The function also converts the value, search, and replace parameters to strings if they are not strings to ensure the function works with non-string inputs.

Example

I can use the function in cases like the following.

ii

The result returned will be as follows

i

  • The value assigned to the variable a by the expression replaces all - characters in the string O-m-nilogin with the "" character
  • The value assigned to the variable c by the expression replaces all characters in the string in the variable b containing the text OmniLogin very great with the input - character
  • The value assigned to the variable f by the expression replaces all characters assigned to the variable d in a string assigned to the variable b containing the text OmniLogin very great with the - character assigned to the variable e

$toLowerCase(value)

This function converts a given value to lowercase. If the value is null or undefined, it returns the original value unchanged. Otherwise, it converts the value to a string and then to lowercase.

Example

I can use the function in cases like the following.

i

The result returned will be as follows

i

  • The value assigned to the variable a by the expression converts the string HELLO WORLD! to the string hello world!
  • The value assigned to the variable c by the expression converts the string OmniLogin assigned to the variable b to the string omnilogin

$toUpperCase(value)

This function converts the input value to uppercase. If the value is falsy (e.g., null, undefined, empty string), it returns the original value unchanged. Otherwise, it converts the value to a string and returns the uppercase result.

Example

I can use the function in cases like the following.

i

The result returned will be as follows

i

  • The value assigned to the variable a by the expression converts the string hello world to the string HELLO WORLD
  • The value assigned to the variable c by the expression converts the string OmniLogin assigned to the variable b to the string OMNILOGIN

$modulo(num, divisor)

This function calculates the remainder of num divided by divisor.

Example

I can use the function in cases like the following.

ii

The result returned will be as follows

i

  • The value assigned to the variable a by the expression divides two numbers 22 and 5 to yield a remainder of 2
  • The value assigned to the variable c by the expression divides two numbers 12 in the variable b and 5 to yield a remainder of 2
  • The value assigned to the variable e by the expression divides two numbers 12 in the variable b and 5 in the variable d to yield a remainder of 2

$filter(data, syntax)

This function filters data based on a JSONPath expression. If the input data is not an object or array, it returns the original data.

Example

I can use the function in cases like the following.

First, create an array of multiple objects in the JavaScript Code node, then assign that array to a variable for use outside the workflow using the omniloginSetVariable function

i

Then use the expression {{$filter([variables.data],'$..color')}} in the Write Log node. When using this expression, the function will retrieve all values of the color key in the data variable

i

The result returned will be as follows

i

$reverse(value)

This reverse function takes a value and reverses the order of its elements. If value is not an array or object, the function returns the original value unchanged.

Example

I can use the function in cases like the following.

i

The result returned will be as follows

i

  • First, assign three values to the variable a to make it an array containing three values 1,2,3
  • The value assigned to the variable b by the expression reverses the order of elements in the variable a

$shuffle(value)

This shuffle function takes an array value and returns a new array with its elements randomly arranged.

Example

I can use the function in cases like the following.

i

The result returned will be as follows

i

  • First, assign three values to the variable a to make it an array containing three values 1,2,3
  • The value assigned to the variable b by the expression shuffles the order of elements in the variable a

$includes(data, item)

The includes function checks whether an item exists in a dataset data. If data is an array, the function uses the built-in includes() method to check for the existence of item. If data is not an array, the function returns false immediately.

Example

I can use the function in cases like the following.

i

i

The result returned will be as follows

i

  • First, assign three values to the variable a to make it an array containing three values 1,2,3
  • The value assigned to the variable b by the expression checks whether the number 2 is in the a array, returning true, meaning the number 2 is in the a array
  • The value assigned to the variable c by the expression checks whether the number 6 is in the a array, returning false, meaning the number 6 is not in the a array
  • The value assigned to the variable e by the expression checks whether the number 7 assigned to the variable d is in the a array, returning false, meaning the number 7 is not in the a array

$trim(data)

This trim function takes a data value and returns it after removing whitespace from the beginning and end. If data is not a text string, the function converts it to a string before removing whitespace.

Example

I can use the function in cases like the following.

i

The result returned will be as follows

i

  • The value assigned to the variable a by the expression removes whitespace from the text a bc written in the trim function, so the variable a will receive the string a bc after removing whitespace from the beginning and end
  • The value assigned to the variable c by the expression removes whitespace from the text 1 2 345 assigned to the variable b written in the trim function, so the variable c will receive the string 1 2 3 45 after removing whitespace from the beginning and end

$match(value, regex, index, flags)

This match function performs a search and returns the matching result of a regular expression regex in a text string value. The function has the following parameters:

  • value: The text string to search
  • regex: The regular expression to search for
  • index: The index of the match result to return (optional, defaults to -1)
  • flags: Optional flags for the regular expression (optional, defaults to empty)

The function will return:

  • The full match result as a string if index is not specified
  • The match result at the specified index if index is specified
  • An empty string if no match is found
Example

I can use the function in cases like the following.

i

i

i

The result returned will be as follows

i

  • The value assigned to the variable a by the expression searches the string abc and returns the text segment matching the regular expression a
  • The value assigned to the variable c by the expression searches the string abcabcAbcAbc assigned to the variable b and returns the text segment matching the regular expression Ab. Using regexFlags as i means case-insensitive text. Index as 0 means taking the first element matching the regular expression if there are multiple matching texts. Thus, the result retrieves the text segment ab instead of Ab as in the regular expression
  • The value assigned to the variable d by the expression searches the string abcabcAbcAbc assigned to the variable b and returns the text segment matching the regular expression Ab. Using regexFlags as i means case-insensitive text. Index as 1 means taking the second element matching the regular expression if there are multiple matching texts. Thus, the result retrieves the text segment undefined instead of Ab as in the regular expression because the i flag only takes the first element
  • The value assigned to the variable e by the expression searches the string abcabcAbcAbc assigned to the variable b and returns the text segment matching the regular expression Ab. Using regexFlags as g means taking all elements matching the regular expression and case-sensitive. Index as 0 means taking the first element matching the regular expression if there are multiple matching texts. Thus, the result retrieves the text segment Ab as Ab as in the regular expression
  • The value assigned to the variable f by the expression searches the string abcabcAbcAbc assigned to the variable b and returns the text segment matching the regular expression Ab. Using regexFlags as g means taking all elements matching the regular expression and case-sensitive. Index as 1 means taking the second element matching the regular expression if there are multiple matching texts. Thus, the result retrieves the text segment Ab as Ab as in the regular expression because the g flag returns a list of texts ["Ab","Ab"]
  • The value assigned to the variable g by the expression searches the string abcabcAbcAbc assigned to the variable b and returns the text segment matching the regular expression Ab. Using regexFlags as g means taking all elements matching the regular expression and case-sensitive. Index as 1 means taking the second element matching the regular expression if there are multiple matching texts. Thus, the result retrieves the text segment ab instead of Ab as in the regular expression because the gi flags return a case-insensitive list of texts ["ab","ab","Ab","Ab"]
  • The value assigned to the variable i by the expression searches the string abc assigned to the variable h and returns the text segment matching the regular expression Ab. Thus, the result retrieves the text segment "" instead of Ab as in the regular expression because there are no flags, so it is case-sensitive, and the string does not contain text matching the regular expression

$join(data,sep=" ")

This join function concatenates an array of values into a single string, using a specified delimiter. If no delimiter is provided, it defaults to a space. If the input is not an array or is invalid, it returns the original value.

Example

I can use the function in cases like the following.

ii

The result returned will be as follows

i

  • The value assigned to the variable a by the expression converts a variable into an array to contain multiple elements
  • The value assigned to the variable b by the expression joins the a array into a new string. Since there is no sep, the elements in the string are separated by a default space
  • The value assigned to the variable c by the expression joins the a array into a new string. Since there is sep="-", the elements in the string are separated by a - delimiter
Example when using the Set Cookie function of the Cookie node

Here, I will use a JSON file to import cookies into the desired profile.

This is the profile before importing cookies

cookie

First, I will use the Read File Text node to read the JSON file containing cookies. To use that data in subsequent steps, I will assign it to a variable named a

cookie

Then, I will use the Cookie node with the Set Cookie option to import the cookie values read from the file. In the value input section, I will use the expression {{$join([variables.a])}} to convert the data from multiple lines into a single line (since using the Read File Text node converts the data into multi-line text)

cookie

After running, my cookies will be added to the profile

cookie

$find(data, path, value)

This function searches for a single value in a nested object or array data, based on a specified path.

Here is a description of the values in the function

  • path is a string of keys for the values
  • The function iterates through each key in the path, accessing the corresponding property in the object or array data.
  • If the current property is an array, it uses the key as an index; otherwise, it uses the key as a property name.
  • The function returns the first value matching the specified value, or an empty string if no match is found.
Example

I can use the function in cases like the following.

Here, I will create an array containing objects in the JavaScript Code node, then assign that array’s value outside the workflow for use with the omniloginSetVariable formula

i

Then use the expression {{$find([variables.test],'user.name','Alice')}} in the Write Log node to log the search result using the find function. Here, I use the expression user.name corresponding to path because the name value I am searching for is within the user object. If I replace user with name along with the value, I only need to specify name. The value Alice corresponds to value

i

The result returned will be as follows

i

  • The value printed in the Write Log node by the find function with the expression searching for name as Alice in the test variable containing an array. The function returns the first object matching the condition

$findAll(data, path, value)

This is a function that filters an object or array data to find all elements matching a value at a specific path.

Here is a description of the values in the function

  • If data is not an object or array, return it as is.
  • Split the path into individual keys using dots.
  • Iterate through each key in the path and navigate through the corresponding object or array data.
  • If the current value is an object or array, use the key to access its property or element.
  • If the current value is an array, use the key as an index to access its element.
  • If the final value matches the value parameter, include it in the filtered result.
  • Return the filtered result as an array. If no matches are found, return an empty array.
Example

I can use the function in cases like the following.

Here, I will create an array containing objects in the JavaScript Code node, then assign that array’s value outside the workflow for use with the omniloginSetVariable formula

i

Then use the expression {{$findAll([variables.data], 'name','Bob')}} in the Write Log node to log the search result using the find function. Here, I use the expression name corresponding to path, and the value Bob corresponding to value

i

The result returned will be as follows

i

  • The values printed in the Write Log node by the findAll function with the expression searching for name as Bob in the data variable containing an array. The function returns all objects matching the condition