Using Different Functions in Business Rule Widget

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

Introduction

This section describes how you can use different functions in the business rule widget. These functions are common functions that you can use to define a condition. When you define a condition by using business rule functions, the business rule uses the applied operator and then checks the condition. If the condition satisfies, the application performs the intended function. Otherwise, application displays error or stops.

Using Product Function

The “Product” function is used to multiply two different values. Let’s see how you can use the Product function in the business rule.

To use the “Product” function:

  1. To apply the Product function, find the If area.
  2. Under If, find the When box.
  3. Click in the When box, and it displays the list of the available functions.
  1. In the Search box, enter the function’s name (For example: – PRODUCT); the Search box displays Product.
  2. Select the Product function, and the When box displays the Product function as follows:

# Standard code of the Product function
PRODUCT(number1, number2, +)
  1. In the syntax of the PRODUCT function:
    • The number1 variable, the number2 variable represent the numeric values such as 2, 4, 5, 8, etc.
    • In the syntax, the plus sign (+) represents the third numeric value if you want to define it.
  2. When the Product function executes, it multiplies all the numeric values as follows:
    • Numeric value1 x Numeric value2 x Numeric value3???x Numeric value (nth)
  3. In the When box, in the Product function, put the mouse pointer on number1.
  1. Click number1, and the box displays the list of functions.
  1. In the Search box, enter Static, and the list displays the Static function.
  1. Select the Static function, the When box displays the syntaxes: (value,Number),number2,+).
  2. In the syntax, click value and then enter a numeric value (For example: – 2) in place of value.
  1. In the syntax, let Number remain if you want to multiple a number with a number.
Note:-
In place of the Number data type, you can also use other primitive data type.
To select other primitive data type:
i. Click Number, the box displays the list of the primitive data types.
ii. In the list, select the appropriate data type.
  1. In the syntax, click number2, the box displays the list of functions.
  2. In the Search box, enter Static, and the list displays the Static function.
  1. Select the Static function, and the box displays the syntax: (value, Number).
  2. In the syntax, click value and then enter the numeric value (For example: – 4) in place of value.
  1. Click the middle list and then select an operator (For example: – (Equal To) (==)) to check the condition.
  2. Click in the right box, a list of functions expands.
  3. In the list, enter Product, and the list displays the Product function.
  4. In the list, select Product and then apply the Product function as described from Step 5 to Step17.
  5. After you define the conditions in the left and right boxes, the logic of the business rule looks like as follows:

Using Max Function

The ?Max? function returns the maximum value from the list. When you apply the Max function, you need to declare the list of values that is enclosed by square bracket.

To use the “Max” function:

  1. To apply the Max function, find the If area.
  2. Under If, find the When box.
  3. Click in the When box, and the box displays the list of the available functions.
  1. In the Search box, enter Max, and the list displays the Max function.
  2. In the list, select Max, and the list displays the Max function with the syntax: Max (numbers).
  1. In the When box, click numbers, and a list of available functions expands.
  2. In the Search box, enter Static, and the list displays the Static function.
  1. In the list, select Static, and the When box displays the syntax of the Max function as follows:
    • MAX(STATIC(value,List))
  1. In the When box, click value and then enter the list of values: [2,4,6,8,10].
  1. Click the middle box and then select the operator (For example: – ==) to check the conditions.
  1. Click in the right box, and it displays a list of functions.
  2. In the Search box, enter Max, the list displays the Max function.
  3. In the list, select Max and then apply the Max function as described from Step 5 to Step9.
  1. Suppose, you define the list in the right box with the values: [2,4,6,8,9].
  2. After you define the condition in the left and right boxes, and then apply the operator, click Save, and the business rule is configured.

Using Concat Function

In the vDesigner business rule, the “Concat” function adds two or more strings and then returns the concatenated output. Based on the applied operator, the business rule checks the concatenated output and then returns the result.

To use the “Concat” function:

  1. To apply the Concat function, find the If area.
  2. Under If, find the When box.
  3. Click in the When box, and the box displays a list of the available functions.
  1. In the Search box, enter Concat, and the list displays the Concat function.
  2. In the list, select Concat, and the When box displays the syntax of the Concat function as follows:
    • CONCAT(string1, string2, +)
  1. In the syntax:
    • ?string1? represents the first string that is concatenated.
    • ?string2? represents the second string that is concatenated.
    • The ?+? sign is used to add third, fourth or ?nth? string.
  2. In the When box, click string1, and a list expands and then displays available functions.
  1. In the Search box, enter Static, and the list displays the Static function.
  2. In the list, select Static, and the When box displays the following syntax:
    • CONCAT(STATIC(value,String),string2,+)
  1. In the When box, click value and then enter the first string (For example: – My employee ID).
  1. In the When box, click string2, and a list of the available functions expands.
  1. In the Search box, enter Static, and the list displays the Static function.
  2. In the list, select Static, and the When box displays the following syntax:
    • CONCAT(STATIC(My employee id ,String),STATIC(value,String),+)
  1. In the When box, click value and then enter the string (For example: – is 110) that you want to add to the first string.
  1. After you enter the second string, click the middle list and then select the operator (For example: – (Equal to (==)) to check the condition.
  2. Click in the right box, and it displays a list of functions.
  3. In the Search box, enter Concat, and the list displays the Concat function.
  4. In the list, select Concat and then apply the Concat function as described from Step 5 to Step 14.
  1. After you define the condition in the right box, click Save, and the business rule is successfully configured.

Using Addhours Function

This function allows you to add hours to a specific object time. When this function executes, it only adds the hour unit of the time. To add minutes and seconds to the object name, you can use the functions Addminutes and Addseconds,respectively.

To use the “Addhours” function:

  1. To apply the Addhours function, find the If area.
  2. Under If, find the When box.
  3. Click in the When box, the box displays a list of the available functions.
  1. In the Search box, enter Addhours, and the list displays the Addhours function.
  2. In the list, select Addhours, and the When box displays the syntax of the addhour function as follows:
    • ADDHOURS(time,format,hours)
  3. In the syntax, click time, and a list of functions expands.
  4. In the Search box, enter Static, and the list displays the Static function.
  1. In the list, select Static, and the When box displays the following syntax:
    • ADDHOURS(STATIC(value,Datetime),format,hours)
  2. In the syntax, click value and then enter the object time in place of the value parameter as follows:
    • 17:54:44

Note:- To select the format of the value of the object time, put the mouse pointer on format, and a box opens and then displays the formats for year, month, day, hour, minute, and second.

  1. In the object time, the value:
    • 17 specifies the 17 hours
    • 54 specifies the 54 minutes
    • 44 specifies 44 seconds
  1. In the When box, in the syntax, click hours, and a list of functions expands.
  2. In the Search box, enter Static, and the list displays the Static function.
  3. In the list, select Static, and the When box displays the following syntax:
    • ADDHOURS(STATIC(17:54:44   ,Datetime),format,STATIC(value,Integer))
  4. In the syntax, click value and then enter the value (For example:-5) that you want to add to the object time (For example:-17:54:44).
  1. After you define the condition in the When box, click the operator list and then select an operator (For example: – ==) to check the condition.
  2. In the right box, define the condition as described from Step 3 to Step 14.
  3. After you define the condition in the right box, click Save, and the business rule is successfully configured.

Similar to applying the ADDHOURS function, you can also apply the ADDMINUTES and the ADDSECONDS functions. The ADDMINUTES function adds a specific value in the ?minute? unit to a specific object time. The ADDSECOND function adds the value in the ?second? unit to a specific object time.

Was this article helpful?
YesNo