Search 3B Knowledge Base
What is the Rule Engine?
The rule engine is a function in the Form Builder that allows you to create complex rules around how forms behave. This article will look at all the different options available in the rule engine and will explain some use cases
How does it work?
You can have multiple rules active at the same time. Each rule is inclusive of other rules and is in “AND” relationship with them. This means that if you have a rule that checks if Date of Birth is before 1992 resulting in showing another field called “Consent” and you have another rule on Date Of Birth which checks if the date is before 1968 and shows “Pension Scheme”, then both rules will be evaluated.
As you have seen, within rules too you can have exclusion – i.e using “OR” logic – e.g – If all/either of the criteria are met, then do something, where you can have multiple criteria. Although rules may seem complex at first glance, they really are quite intuitive and powerful. They really make forms come to live and become more dynamic.
Trigger Operators (The IF clause)
Each trigger function starts with a trigger word –
- Any – This will evaluate that if any of the comparison operators returns TRUE, then continue to the Then clause
- All – Choosing “All” trigger word will require that all comparison operators return TRUE before the rule engine continues to the Then clause
This is what it looks like to have multiple If Clauses:
There are two If Clauses – The first one checks if both First Name and Last Name are equal to James Ridge, and the second one checks if either Date of Birth is not 1992 or Salutation is not Mr.. The rule will display a message if the If Clause is covered.
- This means that if Joe Blogs is completing the form, nothing will happen
- If James Ridge is completing the form, but he has pointed out his salutation is Mrs. then an error will be displayed
- If James Ridge is completing the form, but he has pointed out his Date Of Birth 05 Jul 1992 nothing will happen
Trigger Functions (The Comparison Operators)
The triggers for the execution of a rule are generally generic condition comparison operators between field and static value or between two fields.
The trigger function always starts with the selection of a base comparison field. This is selected from the drop-down selector.
|is equal to||This operator compares the value of one field to be equal to the value of another field. It is case insensitive||
|is not equal to||This operator verifies that two fields/a field and a value are not the same||
|contains||This operator checks if a field contains the value of another field or custom value||
|does not contain||This operator verifies that one field does not contain the value of another field or custom value||
|starts with||This operator checks if a field starts with the value of another field or custom value. It is case insensitive||
|ends with||This operator checks if a field ends with the value of another field or custom value. It is case insensitive||
|does not start with||This operator verifies that a field does not start with the value of another field or custom value. It is case insensitive||
|does not end with||This operator verifies that a field does not end with the value of another field or custom value. It is case insensitive||
|is greater than (or equal)||This operator checks if a field’s value is greater than (or equal) to another field or custom value||
|is smaller than (or equal)||This operator checks if a field’s value is smaller than (or equal) to another field or custom value||
This is what a rule with multiple comparison operators looks like:
In this case, we are checking if all 3 comparison operators return TRUE, we will display a message.
Execution Functions (The Then Clause)
Type of operations allowed are listed below.
|Show||This will show a previously hidden element. This can be applied to both widgets and fields.||Used with conditionals in order to control which fields/widgets a form completer has access to. Example: a field (Birth Date) is marked as hidden by default and this field collects information about the user’s age. If a user indicates that they are under 25, we need to display the Birth Date field to get exact date of birth.|
|Hide||This will hide a previously shown element. This can be applied to both widgets and fields.||Used with conditionals in order to control which fields/widgets a form completer has access to. Example: Signature Widget is added, but a user is not required to complete it if they opt out of it by unchecking a checkbox.|
|Populate||This will allow dynamic population of fields with data either from static (pre-defined) data or from the value of another field.||This is used to set values like “Stage” or “Qualified Lead” based on the responses of some other fields.|
|Display an error*||This will send a toast (message) out to the form and the user will be alerted with the message defined||In a future release, you will be able to control the type of error that is displayed (Success, Warning, Error) which will be displayed with different severity.|
|Make Read-Only||This will make a field read-only and the user will not be able to add/change the field|
|Make Editable*||This will make a read-only field editable and will allow a user to edit/add information||In a future release, you will be able to to make a field which is read only, editabe|
|Make Required||This makes Fields and Widgets required|
|Make Not Required||This makes Fields and Widgets non-mandatory|
|Set Values *||This will set values available for selection on Picklist fields or Multi-Picklist Fields. You can dynamically control which values are displayed/available for a user based on conditions.||Not Currently available|
Use 1 – Conditionally Show Fields based on the input of other fields
You can create rules which will show previously hidden fields
Use 2 – Conditionally Hide Fields based on the input of other fields
You can create rules which will hide previously visible fields
Use 3 – Display a message based on the input of other fields
You can display a message to the user with some information. This message will be displayed at the top of the page.
Use 4 – Conditionally make Fields read-only based on the input of other fields
You can create rules which will disable user input in a field
Use 5 – Conditionally make Fields required/not-required based on the input of other fields
You can create rules which control whether a field is required or not
Use 6 – Conditionally Populate Fields based on the input of other fields
Populating Fields on the main object or related objects controlled through the the input of another field. You can choose a “static” value to be populated into a field or a dynamic value – i.e one which the rule takes from another field.
- You need Visa related fields hidden, if the Nationality field is selected to be British. From a business perspective, British citizens do not need a Visa to be employed, and thus we need to hide all Visa related fields
- You need the signature to be made required if someone states they agree with the terms and conditions. You can create a rule that is based on the checkbox/dropdown “I Agree” after which, the signature pad will be made required before the user can proceed with completing the form
- You want to create a new Related Child record against your contact called “Consent”. There are fields on the Consent object, like Contact (who owns the consent), Date, Signature. You can create a rule that pre-populates those fields based on the value of other fields on the form. The consent Related Object is made hidden so the user does not see it.
- You can also use pre-population for simpler tasks, like pre-populating the value of another field. E.g. if a user indicates they have a car, then change the value of the field “Travel Method” to “Personal Transport”
- Be careful when creating rules, not to create infinite loops – for example if you have two rules checking the state of two fields and a third rule which updates one of the two fields, you may end up in an infinite loop and thus crash the browser
- Always group similar rules together as a good practice