Table of contents
- What is Expression Builder
- IntelliSense & Expression code editor
- Placeholders
- Expression types
- Expression Examples
What is Expression Builder
The skybow Expression Builder is used to easily write and verify expressions and allows you to set parameters dynamically in different places in Modern Forms, List actions, Calculated expressions, Scheduled and Triggered actions.
Different Expression types with Placeholders usage allows to write complex, powerful expressions and with Test functionality verification takes short time.
Depending on the expression type the editor will also have IntelliSense to help writing expressions without breaking away from it.
IntelliSense & Expression code editor
Expression Builder has an editor that allows writing code in a modern way. It supports IntelliSense with Placeholders and depending on the Expression type - standard JavaScript operators. Contextual menu has additional functionality. Also, you could use the search inside the editor with Ctrl + F.
Placeholders
Placeholders are defined using double square brackets: [[...]].
Drag & Drop functionality allows you to add placeholders easily in a current place of editor.
A Search in the upper right corner allows you to find Placeholders in less time.
The placeholders may contain:
- Field values
- Context object values & Functions
- Actions variables
- Actions outputs
- Embedded expressions
Field values
Using field value allows specifying which column value should be returned for the placeholder. Depending on the field type Placeholder can contains of one or more elements separated by a dot '.' (i.e. 'Projects.Customers.Title')
Context object values & Functions
Values for contextual information can be defined in placeholders using the [[@...]] syntax. These can be used to retrieve values (i.e. [[@User.Profile.Department]]) or evaluate contextual functions (i.e. [[@User.IsMemberOfGroup('Portal Owners')]]).
Actions variables
Values for Actions variables can be defined in placeholders using the [[@Variables...]] syntax. These can be used to retrieve values of a variable defined for the scope of actions
To learn more about different Actions and variables used in read Action Builder introduction article.
Actions outputs
Values for Actions outputs can be defined in placeholders using the [[@Actions...]] syntax. These can be used to retrieve values of previously executed actions.
To learn more about different Actions and outputs read Action Builder introduction article.
Embedded expression
When the placeholders content begins with "=" or "{" the placeholder content is evaluated as an assignment or function body expression. This can be very helpful to embed calculations inside template expressions (i.e. "Contract [[=new Date()]").
Expression types
To cater for different uses any expression can be defined in any of the following forms:
- Text expression
- Assignment expression
- Function code expression
Text expression
Text templates are a special form of expressions in which placeholders are replaced by string representation (always returns a string, placeholders are always converted to string before inserted). Placeholders can contain field paths (e.g. [[@User.Email]]) or expression placeholders [[=new Date()]] (begin with equals sign).
This form allows to define textual values in a simpler, more abbreviated and suitable manner than the other forms.
- Syntax: Use plain text containing placeholders to insert dynamically calculated text.
Assignment expression
With assignment expressions you can define texts and values to be calculated using JavaScript-based assignment terms.
- Syntax: The "=" sign at the beginning of expressions signals that it is an assignment expression, otherwise it is evaluated as a template expression. When the assignment expression type has been selected in the expression builder the equals sign does not need to be typed though. Use placeholders in double square brackets to access a field value or context object that is dynamically evaluated.
Function code expression
Using function expressions more complex calculations can be defined. The expression allows using the full scope of JavaScript code as in bodies of JavaScript functions. Values must be returned using 'return <value>;' statements.
- Syntax: Starting with "{" signals that it is a function body expression. In the expression builder the curly brackets don't need to be typed though. Except for the use of placeholders in double square brackets to inject field values, context information, actions variables and outputs the syntax is the same as used in JavaScript function bodies.
NOTE: For the case when function() { } used with Function code expression placeholders should be places outside of it.
Expression Examples
Here are some examples of how to set date time field. We provide the following functions on a date object or placeholder:
|
Set the date plus/minus n minutes. Example: =new Date().addMinutes(15) =[[DateField]].addMinutes(15) |
|
Set the date plus/minus n hours. Example: =new Date().addHours(5) =[[DateField]].addHours(5) |
|
Set the date plus/minus n days. Use addDays(-n) to subtract n days. Example: =new Date().addDays(-10) =[[DateField]].addDays(10) |
|
Set the date plus/minus n mounths. { |
|
Set the date plus/minus n years. =new Date().addYears(-1) =[[DateField]].addYears(1) |
Also, we support date formats for the date time field:
|
Set the date in the different formats. =new Date().format('dd-MM-yy') NOTE: Tree-digit date formats like 'MMM' or 'ddd' doesn't support language localization. This format will return in English language. |