Using Different Functions in Business Rule Widget
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:
- To apply the Product function, find the If area.
- Under If, find the When box.
- Click in the When box, and it displays the list of the available functions.
- In the Search box, enter the function’s name (For example: – PRODUCT); the Search box displays Product.
- Select the Product function, and the When box displays the Product function as follows:
# Standard code of the Product function PRODUCT(number1, number2, +) |
- 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.
- 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)
- In the When box, in the Product function, put the mouse pointer on number1.
- Click number1, and the box displays the list of functions.
- In the Search box, enter Static, and the list displays the Static function.
- Select the Static function, the When box displays the syntaxes: (value,Number),number2,+).
- In the syntax, click value and then enter a numeric value (For example: – 2) in place of value.
- 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. |
- In the syntax, click number2, the box displays the list of functions.
- In the Search box, enter Static, and the list displays the Static function.
- Select the Static function, and the box displays the syntax: (value, Number).
- In the syntax, click value and then enter the numeric value (For example: – 4) in place of value.
- Click the middle list and then select an operator (For example: – (Equal To) (==)) to check the condition.
- Click in the right box, a list of functions expands.
- In the list, enter Product, and the list displays the Product function.
- In the list, select Product and then apply the Product function as described from Step 5 to Step17.
- 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:
- To apply the Max function, find the If area.
- Under If, find the When box.
- Click in the When box, and the box displays the list of the available functions.
- In the Search box, enter Max, and the list displays the Max function.
- In the list, select Max, and the list displays the Max function with the syntax: Max (numbers).
- In the When box, click numbers, and a list of available functions expands.
- In the Search box, enter Static, and the list displays the Static function.
- In the list, select Static, and the When box displays the syntax of the Max function as follows:
- MAX(STATIC(value,List))
- In the When box, click value and then enter the list of values: [2,4,6,8,10].
- Click the middle box and then select the operator (For example: – ==) to check the conditions.
- Click in the right box, and it displays a list of functions.
- In the Search box, enter Max, the list displays the Max function.
- In the list, select Max and then apply the Max function as described from Step 5 to Step9.
- Suppose, you define the list in the right box with the values: [2,4,6,8,9].
- 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:
- To apply the Concat function, find the If area.
- Under If, find the When box.
- Click in the When box, and the box displays a list of the available functions.
- In the Search box, enter Concat, and the list displays the Concat function.
- In the list, select Concat, and the When box displays the syntax of the Concat function as follows:
- CONCAT(string1, string2, +)
- 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.
- In the When box, click string1, and a list expands and then displays available functions.
- In the Search box, enter Static, and the list displays the Static function.
- In the list, select Static, and the When box displays the following syntax:
- CONCAT(STATIC(value,String),string2,+)
- In the When box, click value and then enter the first string (For example: – My employee ID).
- In the When box, click string2, and a list of the available functions expands.
- In the Search box, enter Static, and the list displays the Static function.
- In the list, select Static, and the When box displays the following syntax:
- CONCAT(STATIC(My employee id ,String),STATIC(value,String),+)
- In the When box, click value and then enter the string (For example: – is 110) that you want to add to the first string.
- After you enter the second string, click the middle list and then select the operator (For example: – (Equal to (==)) to check the condition.
- Click in the right box, and it displays a list of functions.
- In the Search box, enter Concat, and the list displays the Concat function.
- In the list, select Concat and then apply the Concat function as described from Step 5 to Step 14.
- 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:
- To apply the Addhours function, find the If area.
- Under If, find the When box.
- Click in the When box, the box displays a list of the available functions.
- In the Search box, enter Addhours, and the list displays the Addhours function.
- In the list, select Addhours, and the When box displays the syntax of the addhour function as follows:
- ADDHOURS(time,format,hours)
- In the syntax, click time, and a list of functions expands.
- In the Search box, enter Static, and the list displays the Static function.
- In the list, select Static, and the When box displays the following syntax:
- ADDHOURS(STATIC(value,Datetime),format,hours)
- 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.
- In the object time, the value:
- 17 specifies the 17 hours
- 54 specifies the 54 minutes
- 44 specifies 44 seconds
- In the When box, in the syntax, click hours, and a list of functions expands.
- In the Search box, enter Static, and the list displays the Static function.
- In the list, select Static, and the When box displays the following syntax:
- ADDHOURS(STATIC(17:54:44 ,Datetime),format,STATIC(value,Integer))
- 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).
- After you define the condition in the When box, click the operator list and then select an operator (For example: – ==) to check the condition.
- In the right box, define the condition as described from Step 3 to Step 14.
- 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.