New to Liquid? We recommend checking out our Crash Course on Liquid article before diving into these scripts.
The Liquid markup language can be leveraged in some very powerful ways to enhance business solution workflows in Onit; we recommend our Crash Course on Liquid as a good primer if you're just getting acquainted with the language, but that article just skims the surface of Liquid's potential.
Below, we've documented a handful of the Liquid scripts we commonly use and some long-winded scripts we don't want to rewrite from scratch when building Apps.
Tip: When using Liquid, remember that the Liquid Editor is your friend!
You can test out most of the scripts detailed below against Records in your App, provided any custom Fields/values (highlighted in the examples below in red) have been created/substituted for and the script operates within the context of a Record. (i.e., the Liquid Editor won't be helpful when evaluating Liquid operating from a notification context. More on context below.)
A Word on Context
It's important to remember the availability of variables you request depends on the context in which your Liquid is being evaluated.
For example, if you are using Liquid to populate the initial value of a Field on the Launch Form, you won't be able to access that Record's Field values since the Record hasn't been submitted yet. In other words, the context of the Launch Form before submission has access to a limited set of variables.
On the other hand, if you're using Liquid to run a Field Calculation, you will have access to any of the other Field values set on Record submission since Field Calculations don't run until after a Record has been submitted.
Although this is not an exhaustive list, below, we've detailed most of the variables available for the unique contexts of Launch Forms, Field Calculations, and notifications.
Launch Form Variables
The following variables are accessible from a transaction's Launch Form (i.e. before the Transaction Initiated Business Rule has fired):
- current_user: The current user
- now: The current datetime
- atom_number: The unique number assigned to each transaction on launch
Field Calculation Variables
The following variables are accessible for Field Calculations:
- All of the Record's Fields
- atom_number: The unique number assigned to each Record on launch
- requester: An array of variables about the requester that submitted the transaction
- phase: The Phase a Record is currently in
- phase_id: The number assigned to a Phase based on its sequential order
- roles: This array includes the Role names and the email addresses of users assigned to those Roles on a given transaction
Notification Variables
In addition to the variables available to Calculated Fields (listed above), the following variables are also accessible for notifications:
- endorsements: An array of variables about the endorsement status of all assigned Approvers on a transaction
- recipient: The email address of the notification's recipient
- corporation: An array of variables about the environment the transaction belongs to
- app: An array of variables about the app the transaction belongs to
- view_request_url: Outputs a link to access the transaction from which the notification was sent.
List of Liquid Filters and Tags
Tags
{% activity_log %}
{% attachment_link %}
{% comment_attachment_link %}
{% get_image %}
{% get_text %}
{% anonymous_attachment_url %}
{% create_launch_url %}
{% app %}
{% param %}
Filters
Combos / MultiSelects
{{ atom | combo_value: '<field_name>'}}
{{ atom | combo_display: '<field_name>' }}
Date Formatting
to_date
short_time
long_time
short
long
when
Date Math
add_years:'number'
subtract_years:'number'
add_months:'number'
subtract_months:'number'
add_days:'number'
subtract_days:'number'
add_business_days:'number'
subtract_business_days:'number'
subtract_date:'date'