Onit Documentation

Miscellaneous Liquid Examples

by David Goldfarb Updated on

Put more detail about changes into the history log 

By default, the history in each transaction just says "[user] edited the [app name] Request Form." For more detail, create an "Add History" action, with this as the Message:

{{current_user.name}} updated the following attributes: 
{% for change in atom.changed_values %} 
{% unless change.field_name == 'updated_at' or change.display_name == blank %} 
{%unless change.previous == blank and change.current == blank%} 
{{ change.display_name }} ({{change.field_name}}) : {{ change.previous }} > {{change.current}} <br> 
{% endunless %}
{% endunless %}
{% endfor %}

If you are referencing custom Fields, you must prepend 'p_' before the Field name. 

E.g., p_custom_Field

Note: The atom.changed_values array changes between each execution of any Business Rule even if the Record has not been updated between calls. When hanging logic off an atom.changed_valuesarray you must reference the first instance of the array directly after the Record updates. 

For example, a Record is updated and a Transaction Phase Change Business Rule fires to send a notification, then a Transaction Updated Business Rule fires to check the atom.changed_valuesarray for specific changes. The Transaction Updated Business Rule will not return the correct results because the atom.changed_values array has been mutated between the two calls, even though the Record was not updated twice. If the atom.changed_values array must be referenced after another Business Rule fires you should park the returned array in a hidden Field, then reference the Field.

Activity Log

This code places an already formatted view of the activity log into an email.

{% activity_log %}

If you want to limit the number of entries, include a number

{% activity_log 3 %}

Iterate/Loop Through All Documents Associated with a Record/Transaction

Suppose we have record, and that record has a field of type DocumentFolder that holds a collection of documents. What we want is to iterate over that collection and extract information from each one of those records. So, basically what we have to do is iterate over the documents property of the atom object, like this:

{% for doc in atom.documents%}
{% if doc.tags contains "doctag"%}
<a href="https://environment.onit.com/rest/documents/{{doc.id}}/download" download>{{doc.name}}</a><br>
{% endif%}
{% endfor%}

In this case we are creating an html <a> tag per document that would allow us to download the corresponding document upon clicking the link. Notice as well use of "doctag" which is basically the name of the DocumentFolder field.

Ending a loop with the Break tag

{% for update in matter_status_updates %}
{% if update.name == 'Manufacturing Supply Agreement - Acme' %}
{% assign found = true %}
{% break %}
{% endif %}
{% endfor %}
{{ found }} 

URL encode

{% assign url = '[{"operator":"like","value":"Finance","property":"p_disclosure_certification_type","type":"text"},
 {"type": "sorting","sort": "p_disclosure_certification_type", "dir": "asc"},
 {"type": "sorting", "sort": "p_question_id", "dir": "asc"},
 {"type": "sorting", "sort": "p_disclosure_name", "dir": "asc"}]' %}
 {{ url | url_encode }} ->  %5B%7B%22operator%22%3A%22like%22%2C%22value%22%3A%22Finance%22%2C%22property%22%3A%22p_disclosure_certification_type%22%2C%22type%22%3A%22text%22%7D%2C%7B%22operator%22%3A%22like%22%2C%22value%22%3A%22Include%22%2C%22property%22%3A%22curr_state_name%22%2C%22type%22%3A%22string%22%7D%2C%7B%22type%22%3A+%22sorting%22%2C%22sort%22%3A+%22p_disclosure_certification_type%22%2C+%22dir%22%3A+%22asc%22%7D%2C%7B%22type%22%3A+%22sorting%22%2C+%22sort%22%3A+%22p_question_id%22%2C+%22dir%22%3A+%22asc%22%7D%2C%7B%22type%22%3A+%22sorting%22%2C+%22sort%22%3A+%22p_disclosure_name%22%2C+%22dir%22%3A+%22asc%22%7D%5D

Execute an Action from an Email Button

You can use the filter execute_reaction_url to create an email button that will trigger an action, and then redirect the user afterwards. The filter format looks like this:

{{ atom | execute_reaction_url: 'action name', 'redirect type', 'authentication' }}

Redirect Types:

Message: This leaves the user on a blank page that displays the last message given

Atom: This places the user on the Record detail page (honors suite preferences, if relevant)

Dashboard: This places the user on the App dashboard (honors suite preferences, if relevant) 

So, in the example below, we have already configured a "Return Message" action and named it "Show me a message". Now we set up a Business Rule that fires a notification action. The notification action includes this:

{% assign button_url = atom | execute_reaction_url: 'Show me a message', 'message' %}
{{ 'Click here' | button_link: button_url}}

When the user receives the notification in their email, they will see the button. When they click on it, they will be taken to a page that is blank, except for the message sent by the "Show me a message" action.

If the redirect parameter had been different:

{% assign button_url = atom | execute_reaction_url: 'Show me a message', 'atom' %}
{{ 'Click here' | button_link: button_url}}

{% assign button_url = atom | execute_reaction_url: 'Show me a message', 'dashboard' %}
{{ 'Click here' | button_link: button_url}}

Then clicking on the button would take them to the transaction detail page, or the app dashboard, respectively. The message would display in the standard system message format.

The authentication parameter is not required. If you do set it, there are two options:

  • authenticated_user
  • email_recipient

Authenticated_user means that the user must log in before anything else happens. If you leave the parameter out, this is also what happens.

Email_recipient means that the action will fire and the user will be redirected to their message without requiring a login.

If you set email_recipient but redirect to atom or dashboard, the user will have to log in before getting redirected, as you might expect. This means a slightly different flow for the two cases:

  • authenticated_user: email button clicked ➙ login ➙ reaction executes ➙ user is placed on the atom
  • email_recipient: email button clicked ➙ reaction executes ➙ login ➙ user is placed on the atom

There are two gotchas here:

  1. If using email_recipient for the authentication, in the Send Notification action, you cannot use "Recipient Roles" as the recipient target of the notification.
  2. If the reaction includes a Return Message action, the message will be returned before the login happens, and in the process of logging the user in and redirecting them, the message gets lost, and the user never sees it.


Daily report list

  1. This code generates a list of the transactions included in the daily digest report.
{% if atoms.size != 0 %}
<p>Here is a list of matters that need accrual estimates:</p>
{% for atom in atoms %}
<p>{{ atom.matter_name }}</p>
{% endfor %}
{% endif %}
  1. This code sorts the atoms by a specific field.
{% if atoms.size != 0 %}
{% assign new_atoms = atoms | sort: "expiration_date" %}
{% for atom in new_atoms %}
<a href="https://avery.onit.com/adhoc_approval/atoms/{{atom.id}}/">{{ atom.name }}</a><br>
{% endfor %}
{% endif %}
Previous Article Emails and Links Liquid Examples

© 2024 Onit, Inc.

docs.onit.com contains proprietary and confidential information owned by Onit, Inc. that is subject to copyright. Onit presents it exclusively to you for your sole use in conjunction with using Onit products. No portion of the materials contained herein may be used for any other purpose. No portion of the materials contained herein may be shared with third parties or reproduced in any form.