A Business Rule is like a set of instructions or rules that tells an app what to do when certain things happen. It helps the app make decisions automatically, like if this happens, then do that. These rules make sure the app works the way you want it to without you having to manage every little step.
A rule usually has two main parts:
Condition: This is the "IF" part that sets when the rule should happen. It checks things like numbers, dates, or other details. For example, a condition could be "if the order is more than $100" or "if the user is younger than 18."
Action: This is the "THEN" part, which tells the app what to do when the condition is met. It can change things, send messages, do math, or show/hide parts of the form. For instance, an action might be "give a 10% discount" or "show/hide specific fields."
By establishing the rules, you establish a framework or logic that governs how your application behaves. These rules ensure consistent and automated decision-making, reducing the need for manual intervention and enhancing the efficiency and accuracy of processes.
What is a Validation?
Validation is a way to make sure that the information entered into a form is correct and follows certain rules. It checks if the data is right before it gets saved or used. For example, validation can make sure that a patient's name is not left blank before submitting an appointment form. This helps keep the data accurate and consistent in an app.
Events in Business Rules and Validations
Events in Rules & Validations give you more control over when and how business rules and validations are applied in your app. They let you specify the exact moments during transactions when certain rules should be triggered, helping to optimize app performance. This means you can ensure that rules are only applied when necessary, based on the specific context or situation.
Here’s a simple breakdown of the different types of events:
On Page Load: This event triggers the conditions as soon as the application page finishes loading.
On Field Interaction: This event triggers the conditions based on user interaction with form fields.
There are a few sub-events within this:
- On Focus: This event triggers the conditions as soon as the user clicks on the field, bringing it into focus.
- Lost Focus: This event triggers the conditions as soon as the user moves away from a field after interacting with it, losing its focus.
- On Value Change/Key Stroke: This event triggers the conditions as soon as the user enters any value in the field or changes any existing. The platform will consider each keystroke in the field as a value change and check the condition for every keystroke.
On Button Element Click: This event triggers the conditions when a specific Button element within the application is clicked.
On Page Submission: This event triggers the conditions when the application is submitted, i.e., clicking a step-action button.
Objective: The application should enforce that no product can have a Quantity of less than 2. Additionally, if the Unit Price is 1000 or more, a 10% discount must be automatically applied to the Total Price, and the Final Price should be displayed.
Scenario:
1. Quantity Validation:
- Event: On Lost Focus (When Quantity field loses its focus in the application)
- Condition: Quantity < 2
- Action: Show validation message "Quantity must be more than 2".
2. Unit Price:
- Event: On Lost Focus
- Condition: Unit price ≥ 1000
- Action: Show "Discount Percentage" and "Discounted Price" fields.
OUTPUT:
These events allow you to control exactly when your business rules or validations are applied, making sure they only run when necessary and improving the performance of your app.
Creation of Business Rules
To automate the school admission process by allowing only eligible students (with a score of 70+ in their previous academic records) to submit their applications. Upon meeting this requirement, the form's "Particulars" section becomes visible for further data submission.
Scenario Breakdown:
1. Eligibility Check: The system checks if the score is 70 or higher.
2. If the score is 70 or above: The "Particulars" section (personal details) of the form will appear so the student can continue filling it out.
3. If the score is below 70: The student will see a message saying they don’t meet the eligibility criteria and cannot continue.
1. Once a form is created, workflow admins are taken to the Rules and Validations page, where they can select "Create Rule." Upon doing so, a popup appears offering options to create a rule, validation, client script, or server script. Choose "Business Rule."
2. After selecting, a pop-up will appear allowing you to create a rule and in the "Rule Details" section give a name to the Rule.
3. Choose when the rule should be executed by selecting an option from the "Execute the Rule on" dropdown menu and Select the Workflow Step.
4. Select an event to determine when a rule should be triggered.
Watch the video below to understand how to create a rule that meets the requirements of the use case mentioned above.
The conditions are structured using IF, ELSE IF, and ELSE statements:
- IF: Checks if a specific condition is true. For example, "IF the user's age is over 18, then proceed."
- ELSE IF: Provides an alternative condition to check if the initial IF condition is false. For example, "ELSE IF the user's age is between 13 and 18, then display a warning."
- ELSE: Covers all other cases if neither the IF nor ELSE IF conditions are met. For example, "ELSE display an error message."
Understanding Vocabulary of Supporting Parameters to Construct Conditions
Compare Type
a) Compare With Value: Select Compare with Value to compare the data capturing field's value that you enter in the application with a value defined by you in the condition.
b) Compare With Field: Select Compare with Field to compare the data capturing field's value with another data capturing field's value in the application.
Vocabulary when adding Actions to a Condition
The Action section is to tell the platform that it should perform the defined action when the above-defined condition becomes true or satisfied.
Go to the Actions section. There are three drop-down fields available.
a) The Action Levels drop-down contains the below options.
- Section Level: This is to apply the action to the selected section based on the condition.
- Element Level: This is to apply the action to the selected element based on the condition.
- Grid Level: This is to apply the action to the selected grid level based on the condition.
b) Actions drop-down, It contains the below options based on the selection in the Action Levels drop-down.
- If you select the Section Level option in the Action Levels drop-down, then the Actions drop-down will display two options.
- Show Section: This is to show the selected section based on the condition.
- Hide Section: This is to hide the selected section based on the condition.
- If you select Element Level in Action Levels, then the Actions drop-down shows the below options.
- Show Element: This is to show the selected data field(visible to naked eye) based on the condition.
- Hide Element: This is to hide the selected data field(vanish from the app-form) based on the condition.
- Enable Element: This is to enable the selected data field(able to insert some data value) based on the condition.
- Disable Element: This is to disable (read-only) the selected data field (not-able to insert some data value) based on the condition.
- Set value: This is to insert a static data value to the selected data field based on the condition.
- Set Field Value: This is to set the real-time data value of a data field to another data field based on the condition in the same application.
- Set Operational Value: This is to set an operation (i.e., Add or Subtract) to the real-time value in a data field irrespective of its type (i.e., Number, Date, etc) based on the condition.
- If you select Grid Level in Action Levels, then the Actions drop-down shows the below options.
- Show Element: This is to show the selected data field(visible to naked eye) based on the condition.
- Hide Element: This is to hide the selected data field(vanish from the app-form) based on the condition.
- Enable Element: This is to enable the selected data field(able to insert some data value) based on the condition.
- Disable Element: This is to disable (read-only) the selected data field (not-able to insert some data value) based on the condition.
- Set value: This is to insert a static data value to the selected data field based on the condition.
- Set Field Value: This is to set the real-time data value of a data field to another data field based on the condition in the same application.
- Set Operational Value: This is to set an operation (i.e., Add or Subtract) to the real-time value in a data field irrespective of its type (i.e., Number, Date, etc) based on the condition.
Utilizing business rules, you can now precisely define values for Link fields and transfer values from other fields (Set Field Value), such as Text and Calculate (String), in our application. This improvement empowers the Link field with dynamic hyperlinks, superseding the default static hyperlink.
Validation Creation
Let's replicate the same use case scenario as we did for the business rules and generate validations.
1. Required Field Validation:
- CGPA in Percentage: If the CGPA in percentage is less than 70, an error message will appear stating that only students with 70% or higher can continue with the application.
Configuration:
Result:
Creating conditions with Natural Language Processor
NLP (Natural Language Processing) in business rules allows citizen developers to use everyday language to create conditions in business rules, making it simpler and more user-friendly. For developers who feel defining/setting up conditions is a complex job, can express rule conditions in a way that is similar to how we talk or write in the NLP section. The NLP engine understands this language and converts it into the necessary instructions for the platform to follow. This means developers can create rules more easily and quickly without cussing on setting up conditions manually. NLP makes the process more accessible and intuitive, helping developers focus on the logic and requirements of their business rules rather than getting caught up in technical details.
Refer to the video below to understand the implementation in the platform.