Understand Expressions in the SnapLogic Platform
This page is no longer maintained (May 13, 2026). For the most current information, go to Understand Expressions in the SnapLogic Platform
This page and all the pages within have been migrated to our documentation site. To access the most current content, go to Understand Expressions.
In this article
Overview
The SnapLogic expression language is a utility that is available to Snaps. You can use expressions (JavaScript syntax) to access functions and properties to set field values dynamically. You can also use the expression language to manipulate data. Learn more about Using Expressions.
Operators
Comparison Operators | Description |
|---|---|
(>, >=, <, <=, ==, !=) | Similar to the JavaScript comparison operators except that strict equals (===) and strict not equals (!===) are not supported. |
Logical Operators | |
(&&, ||, !) | Similar to the JavaScript logical operators. |
String Operators | |
(+) | Similar to the JavaScript string operators except that the shorthand assignment operator (+=) is not supported. |
In this section
- Using Expressions
- JSONPath
- Parameters and Fields
- Global Functions and Properties
- Base64 Functions and Properties
- Date Functions and Properties
- Digest Functions and Properties
- JSON Functions and Properties
- Math Functions and Properties
- Number Functions and Properties
- Object Functions and Properties
- Pipeline Functions and Properties
- String Functions and Properties
- SL Functions and Properties
- Snap Functions and Properties
- Expression Language Examples
- Expression Libraries
- ICONV - Encode and Decode Functions
- Array Functions and Properties
- The Match Control Operator
- HTML - Encode and Decode Functions
- Task Properties and Functions
- GZip Functions and Properties
Arithmetic Operators | Description | Example |
|---|---|---|
(+, -, *, /) | Similar to the JavaScript arithmetic operators except that increment (++) and decrement (--) are not supported. All arithmetic operators return a floating point number. If an integer is desired, then the global function {{parseInt}} should be used to cast the arithmetic expression as an integer. | 1/2 = .5 |
Spread Operator | ||
(...) | This operator makes it easier to build arrays, objects, and call functions where the list of arguments is built at runtime. For instance, while using in an array literal, the value on the right of the operator is inserted into the new array at that position. Similarly, in a function call, the array expands and is used as the arguments to the function. In an object literal, the right side of the operator is another object that has its keys added to the new object. | To build a new array that is made up of another array surrounded by two elements: ["header", ...$body, "footer"]To find the maximum value in an array of numbers: Math.max(...$numbers)To create a new object with some fixed values and entries in the "$extra" object: { first_name: $fname, last_name: $lname, ... $extra } |
Special Operators | ||
Conditional (Ternary) (?) | This operator allows you to specify a value to use based on the result of an expression. Syntax:
|
|
instanceof | The Syntax: |
|
The possible values for the type are: Null, Boolean, String, Number, Object, Array, Date, LocalDate, DateTime, and LocalDateTime. | ||
match | This operator allows you to conditionally evaluate one of a number of expressions based on whether an input value matches a given pattern. Learn more about this operator, match Control Flow Operator. |
|
typeof | This operator returns the type of a value as a string. The possible return values are: "boolean", "number", "string", "object", and "array". Syntax: |
|
in | This operator returns true if the property name or array index is in the given object or array. Syntax:
|
|
Comments
You can add notes to your expressions using comments. A comment starts with '/*' and ends with '*/', for example:
/* say hello */ "Hello, World!"
The comment is ignored when evaluating the expression—it is only for the reader's benefit.
Operator Precedence
Operator Type | Individual Operators |
|---|---|
member |
|
call |
|
negation |
|
multiply/divide |
|
addition/subtraction |
|
relational |
|
equality |
|
logical-and |
|
logical-or |
|
comma |
|
Unsupported Operations
Assignment
Creating variables and assigning values is not supported
Example: var temp = 10
Short hand assignment
Example: count += 5
Strict equals
Example: first === last
Strict not equals
Example: first !== last
Increment
Example: count++
Decrement
Example: count--
Accessing Document Values
To access values in a document, you can use JavaScript object accessors.
For a given document data:
{
first_name: "James",
last_name: "Smith"
}
The expression $first_name would return the 'first_name' property which is James.
You can also access the 'first_name' property by using array notation $['first_name'].
JavaScript array accessors can be used also if the object is an array/list.
For a given document data:
[ 1, 2, 3]
$[1] would return the value 2.
Complex Example:
{
names: ["Joe", "Bob", "Fred"]
}
$names[2] would return the value Fred.
Arrow Functions
You can create custom expression language functions using the arrow function syntax:
// A function that takes multiple parameters:
(param1, param2, ..., paramN) => expression
// A function that takes a single parameter does not need parentheses:
(param) => expression
param => expression
// A function with no parameters requires parentheses:
() => expression
// Function parameters can also have default values
(param1 = defaultValue1, param2 = defaultValue2, ..., paramN = defaultValueN) => expressionThese functions can be passed to other functions that accept callbacks, like Array.map() or Array.filter(), or they can be put into an expression library for use in any expression property in your Pipelines.
Example
To multiply all numbers in an array by ten:
[1, 2, 3].map(x => x * 10)
Result:
[10, 20, 30]