Defining expressions in Declare Expression rules
Define how your application calculates target properties by building expressions. When you build expressions, you create relations between properties so that an application can automatically update property values at run time. As a result, you increase the level of automation and flexibly respond to changing circumstances.
For example, you can create a Declare Expression rule that automatically calculates shipping costs based on the total weight of all items that a customer orders in an online shop. When the customer adds items to the order and the total weight changes, a Declare Expression rule automatically updates the shipping costs.- In the navigation pane of Dev Studio, click Records.
- Expand the Decision category, and then click Declare Expression.
- In the list of instances of declare expressions, open the instance that you want to edit.
- Optional: To provide additional information about the rule, on the
Expressions tab, in the Overview section,
enter a brief description:
- In the Description field, briefly explain the purpose of the rule.
- In the Usage field, briefly explain the scenarios and elements of your application where the declare expression applies.
- In the Build Expressions section, click Add condition.
- In the IF field, enter or select a property to evaluate at run
time.The list includes properties from the Apply To class that you selected during rule creation. For more information, see Creating Declare Expression rules.
- In the list of comparators, select a comparator to apply during property evaluation.
- In the text field, provide a property to evaluate against the property from the IF field.
- Optional: To define more conditions, click Add a row, add a condition before or after the current condition, and then repeat steps 6 through 8.
- Optional: If you have multiple rows, to apply the result of the expression when any of the rows evaluates to true, click AND, and then click OR.
- In the Then set row for your target property, define how the
declare expression determines the target property:
- To determine the target property as a result of a string, in the list, select Value of, and then, in the text field, enter the string that calculates the property.
- To determine the target property as a result of a decision tree, in the list, select Result of Decision Tree, and then, in the text field, enter a decision tree to compute at run time.
- To determine the target property as a result of a decision table, in the list, select Result of Decision Table, and then, in the text field, enter a decision table to compute at run time.
- To determine the target property as a result of a map value, in the list, select Result of Map Value, and then, in the text field, enter a map value to evaluate at run time.
- Optional: To add more conditions to the expression, click Add condition,
and then repeat steps 6 through 11.
- In the Set row for the target property, provide that you want the
system to apply if all the conditions evaluate to false:
- To determine the target property as a result of a string, in the list, select Value of, and then, in the text field, enter the string that calculates the property.
- To determine the target property as a result of a decision tree, in the list, select Result of Decision Tree, and then, in the text field, enter a decision tree to compute at run time.
- To determine the target property as a result of a decision table, in the list, select Result of Decision Table, and then, in the text field, enter a decision table to compute at run time.
- To determine the target property as a result of a map value, in the list, select Result of Map Value, and then, in the text field, enter a map value to evaluate at run time.
- Click Save.
Previous topic Creating Declare Expression rules Next topic Specifying pages and classes for a declare expression