Say you only want to display a certain field or screen in your app if the response to a field is "No." With GoCanvas, mobile apps can be created that allow users to skip screens and fields in the normal work flow if certain user defined conditions are met. This skipping of screens and fields is called "conditional branching." It is sometimes called "skip logic," too.
How Conditional Branching works
The condition for displaying a screen or field is determined in the settings for the screen or field under the Condition section. When defining the condition for displaying a screen or field, the condition operates on the value of a field that has happened prior to the screen or field where the condition is being applied. The condition can be based upon the value of the field or based upon whether a checkbox is checked or not. If it is based upon a checkbox, the values to be used should be "True," for checked, or "False," for unchecked.
How to set up a conditional screen
An example of conditional branching can be seen in an example application used to gather demographic information about people. On the first screen called Basic Information a checkbox exists called Retired. If the checkbox is checked we want a second screen to be shown called Retiree Information which contains questions specific to a retired person. If the checkbox is not checked, we do NOT want to show the Retiree Information screen.
Example demographic information application layout
Follow the steps below to make the Retiree Information screen conditional on the Retired checkbox field:
- Click on the name of the screen you want to make conditional, in this case Retiree Information.
- If not already open, click the gear icon to open the screen settings.
- Click to open the Screen Condition(s) tab then select New screen condition.
- Select a Condition Screen. Choose the screen that has the field you want your Conditional Screen to depend on. For this App, select Basic Information.
- Select a Condition Field. This is the field that will be looked at to decide whether or not your Conditional Screen will be displayed. Choose the checkbox field, Retired.
- Finish the condition by putting in the Condition Value and Condition. The Condition Value is the value your Condition Field will be compared to. The Condition will be equal, not equal, less than, greater than, less than or equal to, or greater than or equal to. In this app we want our conditional screen (Retiree Information) to show if the checkbox (Retired) is true (checked).
- Once you’ve done that you can continue to edit your App as needed. Don’t forget to click Publish to device when finished!
Adding more than one condition
You can add multiple conditions to a single screen or field. In this example, say you want the Retiree Information screen to appear if the Retired checkbox is selected AND the applicant is at least 60 years old.
- Under the first condition that you set for this screen, select the Click to add field condition button.
- Make sure that the AND option is selected in the drop-down between each condition.
- Select Basic Information as the Condition Screen and Age as the condition field.
- Choose >= (Greater Than or Equal) as the Value since you want the field to appear if the applicant is 60 or older.
- Enter 60 as the Condition Value.
If you want the Retiree Information to appear if the Retired checkbox is checked OR if the applicant is 60 or older, follow the same steps but choose the OR option from the drop-down between conditions.
How to set up a Conditional Field
Conditional fields follow the same rules as conditional screens. To set up a condition field follow these steps:
- Click on the name of the field in your App.
- In the field settings that appear on the left, click the Field conditions tab.
- Click to add a new field condition and enter your condition screen, field, condition, and condition value.
In summary, conditional branching allows your mobile users to skip screens and fields if certain predefined conditions are met. It is set under the Condition section of a screen or field and is based on the value of a previous field in the App.