"Conditional logic" in Axure RP is a system of rules used in interactions to determine whether a case should fire. This feature is primarily used to determine which case should fire when two or more cases exist on the same event (for example on a button widget's OnClick event).
"Conditional expressions" are sets of one or more such rules assigned to cases, describing the scenario in which a given case should fire. "Conditions" are individual such rules—single line items in conditional expressions. We usually just refer to conditional expressions as "the conditions" on a case.
Think of conditional expressions and their host cases as having an "if-then" relationship: if the conditions are met, then the case's actions will be executed.
Conditions must be assigned to specific cases. To add conditions to a case, open that case in the Case Editor and then click the "Add Condition" button at the top. This opens the Condition Builder dialog.
Build individual conditions in the Condition Builder using rows of dropdown menus and text fields. Click the green "+" button to the right of any existing row to add a new row below it.
A useful way to think about conditions is to break each one into three parts: The two items you are comparing, and the type of comparison in between. In other words:
[One value] — [How it compares to] — [Another value]
In the Condition Builder, the first and second fields in each row are the type of value and the specific widget or variable being evaluated.
The third field is the type of comparison (e.g., equals, does not equal, etc.).
The fourth and fifth fields are the type of value and the specific value to which you are comparing the first item.
When you're done adding conditions, click the "OK" button in the Condition Builder to return to the Case Editor and choose the actions that will happen when your new conditions are met.
LEARNING AND RESOURCES
AXURE SHARE ENTERPRISE
INSTALLATION TROUBLESHOOTING GUIDES
THE "ALL" OPERATOR
If all conditions must be true in order for the expression to be satisfied (an "and" statement), choose "all" from the dropdown at the top of the Condition Builder ("Satisfy all of the following").
You might use the "all" option when checking that a user entered the right username and the right password.
This is the default setting when adding multiple conditions.
THE "ANY" OPERATOR
If any one of the conditions can be met for the expression to be considered satisfied (an "or" statement), choose "any" from the dropdown at the top of the Condition Builder ("Satisfy any of the following").
You might use the "Any" option when making sure that a user entered either their home, mobile, or work phone number, in a form where only one is required.
MULTIPLE CASES WITH CONDITIONS
An event can of course have multiple cases, and each case can potentially have its own conditions. Below are a few scenarios that use conditional logic. In the section "IF and ELSE IF", we explain how to manage conditions in these different scenarios.
For example, the submit button on a login form might have two cases. The first case could handle a successful login with the action of going to the next page. The second case, for an incorrect login attempt, could show an error message.
In a more complex login form prototype, there might be more cases to handle. Consider a third case to handle a login to a different user account type, for example.
In the login example above, only one case should ever fire at a time. There are also times when multiple cases should fire.
In a registration form with many required fields, the page might show any of several different messages if different fields have not been completed correctly—including possibly showing multiple messages at the same time.
© 2002-2016 Axure Software Solutions, Inc. All rights reserved. Axure ® is a registered trademark of Axure Software Solutions, Inc.
TYPES OF CONDITIONS
You can build conditions based on the following types of values:
Value: An alphanumeric value or an expression.
Value of variable: The current value stored in a variable.
Length of variable value: The length (in number of characters) of a variable value.
Text on widget: The text on a widget, or the text entered into a text field or text area.
Text on focused widget: The text on the widget that currently has focus.
Length of widget value: The length (in number of characters) in the text on a widget.
Selected option of: The selected option of a droplist or list box.
Is selected of: Check if a widget is in its selected or checked state. Returns "true" or "false".
State of panel: The current state of a dynamic panel.
Visibility of widget: Whether a widget is currently visible. Returns "true" if it is visible, "false" if not.
Key pressed: The key pressed on the keyboard.
Cursor: The cursor's location relative to a widget.
Area of widget: The location of a widget relative to another widget.
Adaptive view: The current adaptive view.
Cases can have more than one condition. Add more conditions to a case when working in the Condition Builder by clicking the green "+" button at the end of any row.
When a case has multiple conditions, you'll need to decide whether all the conditions need to be true, or if just any one of them can be true, in order for the case to fire.
"IF" AND "ELSE IF" STATEMENTS
When you add a single case with conditions to an event, the conditional expression starts with "If…".
When you add a second case to the same event, the beginning of the conditional expression will default to "Else If…". If the second case does not have any conditions of its own, the full conditional expression will be "Else If True". The "Else If" prefix means that the second case will be evaluated only in a scenario where the first case's conditional expression is not satisfied. A case with "Else If True" as the whole of its conditional expression will always fire if the preceding case or cases do not.
In the instance where there are two possible valid logins, you'd need to add conditions to two cases—one for each valid login—and then use an "Else If True" expression for the failed login.
Note that conditional logic cases set to a single event are evaluated in order from top to bottom. The "Else If True" statement must be last. Any cases coming after an "Else If True" case and beginning with "Else If" will never be evaluated.
MULTIPLE "IF" STATEMENTS
Recall the example of the registration form with a submit button that can show many possible error messages indicating incomplete fields. In this example, multiple error messages might be shown at a time. "Else If" statements won't work in this scenario, because only the first case satisfied would fire and the rest wouldn't be evaluated.
For this type of interaction, use multiple "If" statements instead of "Else Ifs". You can toggle conditions (for any conditional cases after the first one on an event) between "Else If" and "If". The "If" statements will all always be evaluated, regardless of how many prior cases on the event have fired.
To switch between "If" and "Else If", right-click on the name of a case that has conditions and choose "Toggle IF/ELSE IF" from the context menu.
In the example of the registration form, a different conditional case can show an error message for each incomplete required field.