Data expressions

Learn how to use our data expressions to extract data from data sources.

Throughout the AdSigner app, data expressions are used to extract data from arbitrary data sources.
You can recognize the expression input field by the function icon:

1 / 1

The label on the right will turn green if the expression is valid. The numbers tell how many values were extracted from the data source with the current expression.

invalid

When focusing on the input, a preview list will open showing the results of the expression for each item in the data source.
Clicking on an item in the preview list will display a popover displaying a tree structure of all available data.
Selecting a value in the popover will insert the corresponding expression.

3 / 3
1
"Samuel Jones"
2
"Norman Price"
3
"Norris Steele"
id
2
name
.firstName
"Norman"
.lastName
"Price"
.fullName
"Norman Price"
title
"Paperboy"
email
"norman.price@adsigner.com"

Mapping example

In this example, our data source is a list of 3 users. Each user is represented as an object with id, name, title and email properties. The preview list that opens when focusing on the input will display all users with the results of the expression.

Data source

[
    {
        "id": 1,
        "name": "Samuel Jones",
        "title": "Fireman",
        "email": "samuel.jones@adsigner.com"
    },
    {
        "id": 2,
        "name": "Norman Price",
        "title": "Paperboy",
        "email": "norman.price@adsigner.com"
    },
    {
        "id": 3,
        "name": "Norris Steele",
        "title": "Station Officer",
        "email": "norris.steele@adsigner.com"
    }
]

To extract the names of the users, we can simply use a name expression.

3 / 3
1
"Samuel Jones"
2
"Norman Price"
3
"Norris Steele"

We can do the same for email.

3 / 3
1
"samuel.jones@adsigner.com"
2
"norman.price@adsigner.com"
3
"norris.steele@adsigner.com"

Filter example

In some cases, like when configuring signature selection criteria, we might want to create a filter expression.
To target only users with the title "Fireman", we can use the following expression:

3 / 3
1
true
2
false
3
false

Operators

View the full list of supported operators in the table below. Operators are sorted by precedence (higher precedence operators are evaluated before lower precedence ones).

OperatorAssociativityDescription
(...)NoneGrouping
f(), x.y, a[i]LeftFunction call, property access, array indexing
!LeftFactorial
^RightExponentiation
+, -, not, sqrt, etc.RightUnary prefix operators
*, /, %LeftMultiplication, division, remainder
+, -, ||LeftAddition, subtraction, array/list concatenation
==, !=, >=, <=, >, <, inLeftEquals, not equals, is element in collection
andLeftLogical AND
orLeftLogical OR
x ? y : zRightTernary conditional (if x then y else z)

We can use operators to create more complex expressions, for example to join values.

3 / 3
1
"Samuel Jones, Fireman"
2
"Norman Price, Paperboy"
3
"Norris Steele, Station Officer"

Functions

The following functions are supported.

FunctionDescription
capitalize(string)Converts the first character of string to upper case and the remaining to lower case.
deburr(string)Deburrs string by converting latin-1 supplementary letters to basic latin letters and removing combining diacritical marks.
defaultTo(value, defaultValue)Checks value to determine whether a default value should be returned in its place. The defaultValue is returned if value is NaN, null, or undefined.
includes(collection, target, fromIndex)Checks if target is in collection using SameValueZero for equality comparisons. If fromIndex is negative, it's used as the offset from the end of collection.
indexOf(string, array)Returns the first index of string or array array matching the value string, or -1 if not found.
join(array, separator)Converts all elements in array into a string separated by separator.
pad(string, length, chars)Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
replace(string, pattern, replacement)Replaces matches for pattern in string with replacement.
slice(array, start, end)Creates a slice of array from start up to, but not including, end.
split(string, separator, limit)Splits string by separator. If limit is provided, only the first limit results are returned.
trim(string, chars)Removes leading and trailing whitespace or specified chars from string.
words(string, pattern)Splits string into an array of its words.
3 / 3
1
false
2
false
3
true