Business Rules & Validations
  • 8 Minutes to read
  • Contributors

    Business Rules & Validations


      Article Summary

      Applying Logical Conditions in Business Applications

      A Business Rule is a logical statement or condition that sets specific criteria or constraints, shaping the behavior of an app-form or actions based on the evaluation of that condition. These rules automate decision-making processes within an app-form, enforcing particular actions or outcomes.

      NOTE

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

      9%20Business%20Rules%20PDF

      Typically, a rule consists of two primary components:

      Condition: This defines the criteria necessary for the rule to be triggered. Conditions can vary in complexity, often relying on the values or states of data fields or variables. For instance, a condition could be "if the order total exceeds $100" or "if the user's age is under 18."

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

      By establishing 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 ensures that data entered into form fields meets specific criteria or requirements, maintaining data integrity, accuracy, and consistency in a business application. For example, ensuring the patient's name field is not left empty before submitting the appointment form.

      Business Rule Creation

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

      USE CASE

      Building an appointment scheduling application for a clinic, allowing patients to schedule appointments with doctors based on their availability. Define business rules to set the behavior of the appointment scheduling process.

      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 fields listed above are essential for patients to schedule appointments with doctors. Customize and expand these 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.

      Ensure the app-form is designed in a user-friendly manner, providing clear instructions and validation to ensure accurate and complete data entry by 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.

      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?