In this Page
...
You can create a library file using your favorite text editor to build the expression. You can make an object literal containing all the values and functions to use.
Note |
---|
You can use the same expression library filename as your project space name, assuming you use the expression library within the shared project space. Else, you may encounter an error when using the Mapper Snap. |
Example 1
Code Block | ||
---|---|---|
| ||
{ prefix: 'test', prefixer: x => this.prefix + x } |
Placing this content in a file named "helpers.expr" and uploading it to your project will make it available for use in Pipelines.
Info |
---|
|
To import a library into a Pipeline:
...
If you would like to explicitly set the name of the library in the lib variable, you can fill out the "As" column in the Expression Libraries table in the Pipeline Properties dialog.
Example 2
The following expression library can be used to generate the start date and end date of the previous month in multiple formats.
Code Block |
---|
{ // Convert the given Date-with-time object into a Date with only the year and month to_month_date: x => Date.UTC(x.getFullYear(), x.getMonth() - 1), // Get the start of the previous month based on the given date or the current time if no parameters are given prev_month_start: x => this.to_month_date((x || Date.now()).minusMonths(1)), // Get the end time of the previous month based on the given date or the current time if no parameters are given prev_month_end: x => this.to_month_date((x || Date.now()).withDayOfMonth(1)).minusSeconds(1), prev_month_start_string: x => this.prev_month_start(x).toString().split('T')[0], prev_month_end_string: x => this.prev_month_end(x).toString().split('T')[0], prev_month_start_epoch: x => this.prev_month_start(x).getTime(), prev_month_end_epoch: x => this.prev_month_end(x).getTime() } |
...