Business Rules & Validations
  • 27 Feb 2024
  • 9 Minutes to read
  • Contributors

    Business Rules & Validations


      Article Summary

      An overview of how to apply logical conditions to the form element fields of a business application

      A Business Rule is a logical statement or condition that specifies certain criteria or constraints. It defines the behavior of an app-form or actions that should be taken based on the evaluation of that condition. Rules are used to automate decision-making processes in an app-form and enforce specific actions or outcomes.

      NOTE

      CDs can seamlessly export Business Rules to their local systems in PDF format.

      9%20Business%20Rules%20PDF

      A rule typically consists of two main components:

      Condition: This defines the criteria that need to be met for the rule to be triggered. Conditions can be simple or complex, depending on the requirements. They are usually based on the values or states of data fields or variables. For example, a condition can be "if the order total is greater than $100" or "if the user's age is below 18."

      Action: This specifies the desired outcome or behavior that should be performed when the condition is met. Actions can include modifying data fields, triggering notifications, performing calculations, sending emails, or invoking other processes. For example, an action can be "apply a 10% discount to the order" or "Show/Hide Fields."

      By defining rules, you establish a set of guidelines or logic that govern the behavior of your application. These rules ensure consistent and automated decision-making, reducing the need for manual intervention and improving the efficiency and accuracy of processes.

      What is a Validation?

      Validation refers to the process of ensuring that the data entered into form fields meets certain criteria or requirements. It helps to maintain data integrity, accuracy, and consistency within a business application. Example: Ensure that the patient's name field is not left empty before submitting the appointment form.

      Business Rule & Validation Creation

      1. Business Rule

      Let's understand the business rules configuration with a use case.

      USE CASE
      You're building an appointment scheduling application for a clinic. The application allows patients to schedule appointments with doctors based on their availability. You want to define business rules to set the behavior of the appointment scheduling process.

      In the following sections of this article, we will explore different configurations of business rules within the context of the appointment scheduling application use case. These configurations will help us understand how rules can be defined to determine the behavior and actions of the application.

      Let's consider the following fields that are part of the app-form for scheduling appointments in our scenario:

      1. Patient Information:
        1. Full Name: Text field to capture the patient's full name.
        2. Age: Numeric field to capture the patient's age.
        3. Sex: Radio buttons to choose the patient's sex.
        4. Parental/Guardian Consent: Checkbox or radio buttons to indicate if parental consent is required for patients under 18 or above 65.
        5. Parent/Guardian Name:
        6. Issue Urgency: 
        7. Message on the form:
      2. Appointment Details:
        1. Doctor: Dropdown or radio buttons to select the preferred doctor from a list.
        2. Date: Date picker to select the desired appointment date.
        3. Time: Time picker to select the desired appointment time.
        4. Duration: Dropdown or radio buttons to select the duration of the appointment (e.g., 30 minutes, 1 hour).
        5. Reason: Text area or drop-down to capture the reason for the appointment.
        6. Delivery Due Date: Date picker to select the delivery date.
      NOTE

      The above fields provide the necessary information for patients to schedule appointments with doctors. You can customize and expand the fields based on your specific requirements, such as adding additional contact details (phone number, email), attaching files (medical records), or integrating with a calendar system for availability synchronization.

      Make sure to design the app-form in a user-friendly manner, providing clear instructions and validation to ensure accurate and complete data entry from the users.

      Single Condition Rule

      Condition: If the patient is below 18 years of age.

      Action: Show an additional field to capture guardian permission, such as the Parental Consent.

      Refer to the video below to understand the implementation in the platform.

      Multiple Condition Rule

      Conditions:

      1. If the patient's age is below 18.

       (AND)

      2. If the patient has selected "Yes" for the "Parental Consent" checkbox.

      Actions:

      1. Show additional fields to capture the contact information of the parent or guardian.
      2. Display a notification indicating that parental consent is required for patients below 18 years of age.
      NOTE

      What is the AND operator?

      The "AND" operator is an operator that performs a logical union on two conditions. It only yields a value of "true" when both conditions are true. If one of the two conditions is false, then the logical AND operator yields a "false" value and the platform will not perform any action.

      What is the OR operator?

      This operator returns True if one or the other or both conditions are True. If either condition evaluates to True, platform performs an action accordingly. If neither condition evaluates to True, platform will not perform any action .

      Refer to the video below to understand the implementation in the platform.

      Grouped Conditions Rule

      Grouped Conditions:

      1. If Age field is not empty (AND)

      a. If the patient's age is under 18.

      (OR)

      b. If the patient's age is 65 and above.

      Action: Display a message on the form indicating that patients under 18 require guardian consent and patients aged 65 and above are given priority slots. Show Parental/Guardian Consent, Guardian Name, Guardian Phone Number, Issue Urgency.

      Else Action: Do not show Parental/Guardian Consent, Guardian Name, Guardian Phone Number, Issue Urgency, or any message.

      Refer to the video below to understand the implementation in the platform.

      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.

      Screenshot (103)

      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.
        1. Show Section: This is to show the selected section based on the condition.
        2. 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.
        1. Show Element: This is to show the selected data field(visible to naked eye) based on the condition.
        2. Hide Element: This is to hide the selected data field(vanish from the app-form) based on the condition.
        3. Enable Element: This is to enable the selected data field(able to insert some data value) based on the condition.
        4. Disable Element: This is to disable (read-only) the selected data field (not-able to insert some data value) based on the condition.
        5. Set value: This is to insert a static data value to the selected data field based on the condition.
        6. 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.
        7. 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.
        1. Show Element: This is to show the selected data field(visible to naked eye) based on the condition.
        2. Hide Element: This is to hide the selected data field(vanish from the app-form) based on the condition.
        3. Enable Element: This is to enable the selected data field(able to insert some data value) based on the condition.
        4. Disable Element: This is to disable (read-only) the selected data field (not-able to insert some data value) based on the condition.
        5. Set value: This is to insert a static data value to the selected data field based on the condition.
        6. 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.
        7. 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.
      NOTE
      When specifying a condition in a rule or validation, you encounter expressions like IS, IS NOT, IS EMPTY, etc. These expressions are not explicitly defined in this article because their meanings are intuitive and easily understood.
      NOTE

      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.

      2. Validation Creation

      Let's replicate the same use case scenario as we did for the business rules and generate validations.

      NOTE
      The process of defining/constructing a validation and business rule is same however, the functionality and application would differ as defined at the beginning of this article.

      1. Required Field Validation:

      • Patient Name: Ensure that the patient's name field is not left empty before submitting the appointment form.
      • Appointment Date: Make it mandatory for the user to select a date for the appointment.
      • Issue Urgency: Make it mandatory for users of age above 65.

      2. Date and Time Validation:

      • Future Date: Validate that the selected appointment date is in the future, preventing scheduling appointments for past dates.
      • Working Hours: Check that the selected appointment time falls within the doctor's working hours (e.g., 9 AM to 5 PM).

      Refer to the video below to understand the implementation in the platform.

      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.

      NOTE
      Sometimes, the intended meaning or expression may not be accurately captured in the NLP section. In such cases, our platform might not generate the expected condition as a result. However, you can easily make corrections on the fly to the platform-produced condition and obtain the desired definition for the condition.

      Refer to the video below to understand the implementation in the platform.

      1 BR - NLP GIF

      Best Practices 

      Learn about the best practices that you can keep in mind while creating business rules to get a better outcome.


      Was this article helpful?