To execute actions depending upon current conditions, add a Decision Branch action to your event. A decision branch action consists of at least one rule, and at least one condition test. If the condition test meets the rule, the branch evaluates to "true," and the event continues by executing the subsequent action. To access this action in the Event editor, choose the Basics button from the Actions list.
There are many ways to use conditional logic in an application. As an example, suppose you were tasked with creating a banking application to be used internally by the tellers. The tellers can interact with client accounts, making balance transfers or buying new CDs. Let's say that you want to prevent tellers from making major transactions, reserving this capability for managers. To do this, you could add a Decision Branch action to an On Form Submit event, for an interactive form that compares all of the input fields to a maximum number, and then navigates the user to a different form for manager login.
To build this example with a Decision Branch, you could use the rule "When at least one is true," with a condition test for each input field, comparing it to a variable containing the maximum amount you will allow for teller-initiated transactions. If an input field exceeds this number (use the "Greater than" operator in your expression), the branch evaluates to true and the sub-action is processed. The sub-action would be a Display Form, navigating the teller to a different form for manager login. If none of the input fields exceeded the maximum, the branch would evaluate to false, the sub-actions of the branch would not be processed, and the application would continue.
|Name||This optional property can help with identification when you use multiple decision branches.|
|Expression Type (Rule)||This is the statement that must evaluate to true for the event to continue. For example, the "all" in the statement "When all are true" refers to all of the condition tests added to the expression. Click the Add Rule button to select an expression type. Options include:
|Condition Tests||To evaluate a condition, you build a test that compares two operands. The operands can be fields on a host screen, constants you define, values of controls on a form basically, any of the data elements available to your application at that time.
Either operand can be compared with a constant that you define, by right-clicking the selected data element and choosing Compare with Constant. When using constants, do not use the following characters:
|Operator||The operator used to compare the operands. Select from the following. (Default: equals.)
|Type||The data type of the selected operands. Select either String or Number. (Default: String.)
If the type is String, for example, the statement
|Adding Actions to Events|
|Adding Decision Branches to Events|