Syntax
ApptiveScript has few rules. This page lists all of them.
Value, dot, function
Every expression starts with a value. After that, functions follow, each separated by a dot:
fieldValue('price').multiplyBy(1.19)The result of a function is a value again — which means functions can be chained. It's read left to right:
fieldValue('lastName').concat(fieldValue('firstName'), ', ').isNotEmpty()Which functions are allowed depends on the type of the value to the left of the dot. A text value can use contains(), a number can use round(). → Function reference
Spaces and line breaks between the parts are allowed. For longer chains, this is the more readable form:
fieldValue('quantity')
.multiplyBy(fieldValue('unitPrice'))
.round(2)Functions always have parentheses
Even when they don't need an argument:
| Correct | Wrong |
|---|---|
today() | today |
fieldValue('title').isEmpty() | fieldValue('title').isEmpty |
The exception is properties. They appear without parentheses because they don't calculate anything — they just name part of a value. In the function reference, they're listed with a leading dot:
loggedInUser().emailtrue and false are also properties and appear without parentheses.
Text, numbers, booleans
| Kind | Syntax | Example |
|---|---|---|
| Text | single quotation marks | 'Other' |
| Whole number | no separator | 42, -7 |
| Decimal number | with a dot as the decimal separator | 1.19 |
| Boolean | no parentheses, lowercase | true, false |
Three typos that break an expression
- Double quotation marks (
"Other") aren't valid text. The editor reports an error. - A comma as decimal separator (
1,19) isn't read correctly. Always use1.19. - Capitalization matters:
Trueis nottrue,IsEmpty()is notisEmpty(). A misspelled name is treated as unknown — and an unknown name isn't an error, it's simply blank.
Apostrophes in text don't work
An apostrophe inside a text value can't be written — 'Müller's shop' cuts the text off after Müller, without any error message appearing. Avoid apostrophes in comparison values, or compare against part of the text using contains().
Doing math
For numbers, both notations are available — operators and functions:
(fieldValue('net') + fieldValue('shipping')) * 1.19
fieldValue('net').plus(fieldValue('shipping')).multiplyBy(1.19)| Operator | Function |
|---|---|
+ | plus() |
- | minus() |
* | multiplyBy() |
/ | divideBy() |
Parentheses group terms: (2 + 3) * 4 gives 20.
When in doubt, use the function notation
The editor inserts functions rather than operators when you click things together — and chains of functions can be extended without thinking about operator precedence. Operators are mainly convenient for short formulas.
Combining conditions
There are no keywords for and, or, not — they're functions on a boolean value:
formValues.get('age').greaterThan(17).logicalAnd(formValues.get('terms').isTrue())| Meaning | Syntax |
|---|---|
| and | condition.logicalAnd(otherCondition) |
| or | condition.logicalOr(otherCondition) |
| not | condition.isFalse() |
| if/else | condition.if(then, otherwise) |
Don't mix AND and OR
The interface can only display an expression as rows if it's connected entirely with AND or entirely with OR. If you mix them, the Flow dialog reports:
This expression mixes AND/OR or can't be split into rows. Edit it as a single expression, or use rows with a shared operator (AND only or OR only).
The expression keeps working — it just can no longer be edited via the rows.
Missing values
An empty field doesn't produce an error, but an empty value. Two functions handle that:
fieldValue('nickname').ifUndefined('unknown')
fieldValue('orderNumber').isNotEmpty()ifUndefined() is available on every type. It matters most anywhere further calculation happens — multiplying by an empty field doesn't produce a result, it produces nothing.
What doesn't exist
| Comments | // … and /* … */ are invalid |
| Variables and intermediate steps | an expression is a single line |
| Multiple results | an expression returns exactly one value |
| German function names | names are in English, even in the German interface |
Editor error messages
The expression editor shows errors below the field, in English and with internal type names:
| Message | Meaning |
|---|---|
| ASString class has no function named … | This function doesn't exist for this type — check the function reference |
| function needs 1 arguments | Too few or too many arguments in the parentheses |
| Unexpected token … | The expression is incomplete, e.g. a missing parenthesis or a trailing dot |
| No field with id … | The column being referenced no longer exists |
If an expression can't be parsed, the text you entered stays unchanged in the field instead of being converted into blocks. That's the fastest way to spot a typo.
Next
- Referencing values — what an expression starts with
- Building conditions — comparisons, AND/OR, branches
- The expression editor — token view, picker, sample result
- Function reference — every function by type
- What is ApptiveScript