Creating Business Rule

This post is referring to Vahana 2 (beta version). To check the document for production, please go to vDesigner-v1.0

Introduction

In the vDesigner module, the business rule manager is used to create a new business rule. In the business rule manager, the application user implements a logic by defining the expression-based conditions or by using vDesigner functions. When a business rule is executed, the application checks if the user’s action satisfies the condition in the business rule.

If the user’s action satisfies the condition, it returns the “true” value, and the application performs the expected function, or it returns the “false” value. You can create a business rule as follows:

Creating a New Business Rule

The business rule is created on the element level or the task level based on the functional requirements. When an end-user performs the function in the application, the application executes a configured business rule. It checks if the user’s action satisfies the condition in the business rule. If the user’s action satisfies the condition, it returns the “true” value, and the application performs the expected function.

To create a business rule, you need to access the business rule manager. You can access the business rule manager in the following ways:

  • On the Event Configuration page, in the Business Rule box, click the application tree icon () while implementing a task, and then create a business rule.
  • On the vDesigner module’s home page, see the left navigation panel, and then click the BRM icon () to access the business rule manager.

To access the business rule manager, you can use one of the above navigation steps. You are recommended to access the business rule manager from the left navigation panel. The advantage of accessing the business rule manager from the left navigation panel is that it allows you to focus on the algorithm of the business rule without worrying about other implementation tasks. After you create a business rule, you can select it when you configure the related task.

If you plan to create a business rule related to a common context (for example:- The application must display the Enter OTP box after the user clicks the Get OTP link), you can use that business rule at several places.)

To create a new business rule:

  1. On the vDesigner module’s home page, see the left navigation panel.
  1. In the left navigation panel, click the BRM icon (), and the Business Rules page opens in the middle panel.
  1. On the Business Rules page, click Create New, and the Create New page opens.
  1. On the Create New page, enter the details of a new business rule as follows:
    • Name:- In this box, enter the name of the new business rule.
    • Tags:- In this box, enter an alphanumeric value. This value is treated as a tag. The tags are used to manage a business rule or collection of business rules. You can use the tag to search for a business rule or a collection of several business rules later. The tags are used as an identifier.
    • Description:- In this box, you can enter a reason to create the business rule or a brief definition of the business rule.
  1. After you enter the details of the business rule, see the IF block.
  2. The IF block provides two options as follows:
    • OR: Select this option if you want the business rule to check either two or more conditions for returning the result.
    • AND: Select this option if you want the business rule to check all the conditions for returning the result.
  3. Under the “IF” block, perform the following functions to define the logic of the business rule:
Box/FieldDescription
WhenIn this box, you can enter/pass three types of arguments:
1. Static Number: This argument type allows you to pass the static value, string, or any other data type.

#Sample Syntax
Static(“2”)

2. Data Path: This argument type allows you to select the data path. The data path denotes the inbuilt JSON based data stores that are used to store and fetch the data based on the business related requirements. In the When block, press CTRL + SPACEBAR, the list of data paths expands. Select the desired data path.

3. Function :- This argument allows you to select different arithmetic/logical/business rule functions to build the logic of the business rule.  

The list of functions available are as follows:
a. AVG(number1: Number, number2: Number)
b. COUNT(list: List of Number)
c. SUM(number1: Number, number2: Number)
d. SUBTRACT(number1: Number, number2: Number) e. PRODUCT(number1: Number, number2: Number)
f. DIVIDE(dividend: Number, divisor: Number)
g. ROOT(root: Number, number: Number)
h. POW(power: Number, number: Number)
i. FACTORIAL(number: Number)
j. MAX(numbers: List of Number)
k. MIN(numbers: List of Number)
l. SORT(sortType: String, list: List)
m. RANDOM(string: String)
n.CONCAT(string1: String, string2: String)
o. SUBSTR(string: String, start: Number, end: Number) p. HEX(string: String)
q. CONTAINS(string: String, subString: String)
r. UPPER(string: String)
s. LOWER(string: String)

#Sample Syntax
SUM(arg1, arg2, arg3)  

In this expression, the arguments: arg1, arg2, and others can denote the static value, string, or any other data type based on the selected function.  
For example: – SUM(static(“2”), user.name, arg3)
ContainsThis list contains the list of the expressions/operators such as like, ==, < (less than), > (greater than), >= (greater than equal to), etc. Select an operator. The selected operator checks the condition in the business rule.
     
Empty boxIn this box, you need to enter/pass any of three types of the arguments like you entered the arguments in the When box. When the business rule executes, it checks the conditions that are defined in the When box and in this box and then returns the result.
 
  1. After you define the logic of the business rule, click Save, the business rule is created.

Adding a New “When” Block

In the Business Rule panel, you can click the Rule link to add a new When block. When you want the business rule to check two or more conditions for returning the result, you can add more than one “When” block.

To add a “When” block:

  1. On the Business Rule panel, click the Rule link, and a new “When” block is inserted under the default When block.
  1. After you add a new “When” block, define the condition in the “When” block as described in the heading section: Creating a New Business Rule.

Adding a Rule Set

This function allows you to add a new business rule apart from the default business rule. In case of multiple business rules, you can add multiple business rules separately or you can nest a business rule inside another business rule. The set of business rules returns a cumulative result based on the selected “OR” or “AND” condition.

To add a set of multiple rules:

  1. On the Business Rule panel, click the Rule Set link, and the panel adds a new block.
  1. In the new block of business rule, you can perform the following functions:
    • Click the Rule link to add a new “When” block and define the condition in the newly added business rule.
    • Click the Rule Set link to nest another business rule in the newly added business rule.
  2. To define a new condition in the business rule, visit the heading section: Creating a New Business Rule.

Viewing List of Rules

In vDesigner, you can add and manage several business rules on the application level. If you have configured a business rule for one element, you can configure the same business rule for another element. The vDesigner application allows you to view the list of all the business rules that are configured for different elements.

To view the list of business rules:

  1. On the Event Configuration page, first drag a task to the Execution panel.
  2. After you drag the task to the Execution panel, the task expands and displays its properties.
  3. In the Business Rule box, click the application tree icon (), and the Business Rule panel opens.
  4. The Business Rule panel displays the list of the existing business rules in the tile format or list format.

Accessing Business Rule Details

On the Business rule panel, you can access the details of the specific business rule. The vDesigner application displays the following details of the business rule:

  • Rule name
  • Expression of the rule
  • Description of the rule
  • List of references

To access the details of the business rule:

  1. On the Business Rule panel, find the rule (For example: – KS_Rule1) to access its details.
  2. After you find a business rule, click in the tile or list of the business rule, and the Info panel opens and then displays the details of the business rule as follows:
    • Rule name
    • Expression of the rule: It explains the logic of the rule.
    • Description of the rule
    • List of references: It displays two tabs:
      • Current References: This tab displays the details of the references of the current page on which the business rule is configured.
      • Other References: This tab displays the details of the references of other pages on which the business rule is configured.
  3. The Info panel displays the details of the references as follows:
    • <<Screen name>>. <<Element name>>. <<Task name>>. <<Property Name>>

Editing a Business Rule

This feature allows you to edit details of the business rule.

To edit the details of the business rule:

  1. On the Business Rule panel, find the name of the business rule (For example: – KS_Rule1) to edit its details.
  2. After you find the business rule, click the name of the business rule, and the Info panel displays the details of the business rule.
  1. On the Info panel, click the edit icon (), and the Business Rule panel displays the details of the business rule in the editable format.
  2. You can edit the following details of the business rule:
    • Name of the business rule
    • Tag name (The tag name is used as an identifier to categorize a business rule or group of business rules.)
    • Description of the business rule
    • Selection of operators (And/Or)
    • Logic of the business rule
  3. After you edit the details of the business rule, click Save, and the business rule is successfully edited.

Consuming a Business Rule

In the vDesigner application, business rules are managed on the application level. While configuring a task, you can consume a business rule. The vDesigner application allows you to consume one or more business rules for multiple elements.

To consume a business rule:

  1. On the Event Configuration page, in the Task panel, find the task for which you want to consume the business rule.
  2. Drag the task (For example: – Call) to the Execution panel.
  3. The tree of the task expands and displays different properties of the task.
  4. In the tree, see the Business Rule box.
  5. In the Business Rule box, click the application tree icon (), and the Business Rule panel opens.
  6. The Business Rule panel displays the list of the existing business rules.
  1. In the list of the business rules, click the rule that you want to consume, and the Info panel opens.
  2. After you select the rule, click Select, and the selected business rule starts appearing in the Business Rule box.
  1. In the Business Rule box, the name of the selected business rule specifies that the task is consuming the business rule.

Deleting a Reference

This one-click away feature allows you to delete the reference. Deleting a reference means that you do not want to consume the business rule for the respective task. After you delete a reference, you release the business rule that a specific task was using.

To delete a reference:

  1. In the middle panel, on the mobile phone canvas, find the element in which you want to delete the reference.
  2. Click the element, and the property panel of that element opens.
  3. In the property panel, see the Events tab ().
  1. Click the Events tab (), and the property panel displays a list of the available events.
  1. In the list, find the event in which you want to delete the reference.
  2. After you find the event (For example: – onClick), click the Edit Config icon () right to the event name, and the Event Configuration page opens.
  3. On the Event Configuration page, find the Execution panel.
  4. In the Execution panel, find the task (For example: – Call) in which you want to delete the reference.
  5. In the tree of the task, see the Business Rule box.
  6. In the Business Rule box, find the reference that you want to delete.
  1. Click the Close button to delete the reference of the business rule, and the reference is deleted.
  2. Click Save, and the reference is permanently deleted.

To use different functions in the business rule, click here.

Was this article helpful?
YesNo