Business Rules are one of the critical components to building Apps in Onit. While Actions enable you to specify what should happen inside of your App (e.g., an email should be sent, a spreadsheet should be generated), Business Rules enable you to specify when your Action should fire.
For example, an App creator may have created an Action that adds a participant to a Record. A Business Rule could be used to specify exactly when this should happen. The App creator could have the Add Participant Action run when the Record is first created, by tying it to a Transaction Created Business Rule. Alternatively, the App creator could have the Action run when a phase change occurs by instead tying it to a Transaction Phase Change Business Rule. There are over a dozen different types of pre-defined Business Rules, each of which enable you to run an Action at a different time.
In many cases, you can also add a Condition to a Business Rule, which allows you to get even more specific when configuring when an Action should run. For example, you could run an Add Participant Action only if the Record in question had a price field value that was greater than $1,000.
Business Rules are not the only way to run an Action. You can also create a Button that, when clicked by a user, fires an Action.
Before We Start ...
Let's Get Started!
In this example, we create a Transaction Phase Change Business Rule to run an Add Participant Action.
1. Browse to Business Rules
Browse to your App’s Advanced Designer page. In the left-hand pane, click the Business Rules node.
2. Add a New Business Rule
From the Add dropdown, select the type of Business Rule that you want to create. In this example, we want our Action to run when a phase is changed. As a result, we’ll select Transaction Phase Change.
3. Configure the Action
This is your opportunity to specify what will happen when the Business Rule runs.
Provide the Business Rule with a Name.
When naming a Business Rule, we recommend that you be descriptive. This helps other people administering your app understand how it works, and it also serves as a reminder to you in case you forget. The best Business Rule names provide a brief explanation of what will actually happen when the Business Rule fires. In many cases, it’s a good idea to use the same name that you used for the corresponding Action.
Note that you can select a Condition or Action you've preconfigured from each property's dropdown or use their respective New buttons to create a new Condition or Action ad hoc.
See Your Business Rule at Work
Congrats! You’ve created your first Business Rule! Test your Business Rule out by checking that your Action fires when expected.
In this example, we created a Business Rule that adds a Legal Approver when a transaction enters a Phase called Legal Approval.
Types of Business Rules
Below is a complete list of the different Business Rules you can apply Actions to:
- Daily Schedule: The time zone used by the Daily Schedule depends on which Onit data center your Onit environments lives within. For Onit most clients, this will be 3am CST.
- Transaction Initiated: Fires when a new Record is first submitted from the Launch Page. (See Transaction Initiated vs Transaction Created Business Rules note below.)
- Transaction Created: Fires after a new Record has been fully created, (i.e., Phase has been set, participants have been added, etc.). (See Transaction Initiated vs Transaction Created Business Rules note below.)
- Transaction Phase Change: When a Record's phase changes.
- Transaction Updated: When a Record's details are edited.
- Transaction Completed: When a Record is closed.
- Transaction Reopened: When a Record is reopened.
- Transaction Deleted: When a Record is deleted.
- Transaction Restored: When a Record was previously deleted and is now un-deleted.
- Participant Added: When a participant is added to a Record.
- Participant Activated: When a participant becomes active in a phased workflow.
- Participant Deleted: When a participant is deleted from a Record.
- Participant Approved: When a participant approves a Record.
- Participant Rejected: When a participant rejects a Record.
- Participant Reset: When a participant's approval is set back to pending on a Record.
- Participant Approved by Proxy: When a participant's approval is given by a proxy on a Record.
- Comment Added: When a comment is added to a Record.
- Email Received: When an email is received on a Record.
- App Updated: When an App is updated.
- App Deleting: When an App is deleted.
Transaction Initiated vs Transaction Created Business Rules:
The distinction between a Transaction Initiated Business Rule and a Transaction Created Business Rule is slight, but it’s important to understand when to use one over the other.
A Transaction Initiated Business Rule fires right when you hit the Submit Button on your Launch Page. A Transaction Created Business Rule, however, fires after the transaction has been fully created, meaning the transaction's participants have been added, its Phase is set, and any other background operations have run.
For example, you'd want to use a Transaction Initiated Business Rule if what Phase a transaction lands in when it's first created is conditionally dependent on one of its Fields' values.
You would alternatively use a Transaction Created Business Rule if you needed to run an Action that evaluated something about a transaction that’s already been created, such as what Phase it's in.
Advanced Tip: Note that Business Rules fire from specific contexts, limiting their ability to access variables in other contexts. Any Business Rule name that does not begin with "Transaction" will not directly be able to access variables associated with a Record. To direct these Business Rules to the variables in a Record context, prepend atom to any Record-level variables in your Actions' and Conditions' Liquid.