We'll create a simple decision rule that accepts a name of a product, and returns back it's cost and price.
Enter the specific rule properties as follows. To read about the other properties, review the Rules help:
Property | Value | Description |
---|---|---|
Rule Name | DecisionRule_Products | You can choose any meaningful name you like. |
Rule Usage | Empty | This rule usage provides the necessary input and output parameters necessary for a rule's purpose. Select the Empty Rule Usage for this example. |
Rule Type | Decision | This type of rule is meant will launch a special Decision Builder after you save the rule. |
Click Add and create the following Parameters:
Name | Type | Default | Behavior | Length |
---|---|---|---|---|
ProductName | Text | Input | ||
Cost | Number | Output | ||
Price | Number | Output |
Make sure to keep the Default and Length values empty.
Enter the predicate properties as follows:
Property | Value | Description |
---|---|---|
Expression Type | SQL Non Query | There are three options available, we'll do SQL Non Query for this example and then later discuss the other options. |
SQL Body | BEGIN IF :ProductName = 'Apples' THEN | In this Predicate we check if ProductName is Apples, if it is then we set the system parameter Result to 1 indicating that this is the case we want to evaluate. |
Enter the condition value properties as follows:
Property | Value | Description |
---|---|---|
Expression Type | Constant | There are three options available, we'll do a simple Constant and then later discuss the other options. |
Value | 10 | If the Predicate for this case was returned true, then the output parameter Cost will be set to 10. |
Enter the condition value properties as follows:
Property | Value | Description |
---|---|---|
Expression Type | Constant | There are three options available, we'll do a simple Constant and then later discuss the other options. |
Value | 15 | If the Predicate for this case was returned true, then the output parameter Price will be set to 15. |
Add three more cases with the following information:
Predicate Expression Type | Predicate SQL Body | Cost Expression Type | Cost Value/SQL Body | Price Expression Type | Price Value/SQL Body |
---|---|---|---|---|---|
SQL Non Query
| BEGIN IF :ProductName = 'Oranges' THEN | Constant | 2 | Constant | 5 |
SQL Non Query | BEGIN IF :ProductName = 'Microwave' THEN | Constant | 200 | SQL Non Query | BEGIN |
SQL Non Query | BEGIN IF :ProductName = 'TV' THEN | SQL Non Query | BEGIN | SQL Non Query | BEGIN |
Click the Run button on the bottom left. Scroll down to the Rule Result text area and you should see the following result:
{"DATA":{"root_DecisionRule_Products":{"RETVAL":"1","COST":"200","PRICE":"250"}}} |