Branching Navigation:

Using Decision Logic to Define Alternate Paths

The business logic behind an application frequently defines the path a workflow follows through certain decision points. Visualized in a flow diagram, these decision points are often followed by two or more branches, each containing different screens or tasks.

When mapping out a scenario in iRise, this branching navigation is usually represented by a Decision. While Decisions can be purely conceptual, when the need arises, you can build business logic into your simulation by adding data-driven rules that turn your Decisions into functional simulation components.

Watch a Video

Watch this video for a brief demonstration of the topics covered in this tutorial.

What is a Decision in iRise?

Decisions are Directory components (chapters) that are typically added to scenarios as a visual representation of branching navigation flow. In many cases, this conceptual view, along with scenario-level requirements, is enough to validate the business logic.

Decision in a scenario flow

In cases where there is still some ambiguity about the business logic, it often makes sense to incorporate the logic into your simulation in the form of a functional Decision.

Functional Decision

Functional Decisions use rules based on data to determine the path the navigation will follow. The destination for each branch is typically going to be a link to a page in the simulation, but it can also be another Decision or a data operation, and frequently it will navigate through a Clipboard widget to assign a value to a data field.

Checking for an existing customer during new profile creation

For this example, we can imagine that we are running a new validation scenario for the saving of a customer profile. We want to check the user input — the email address specifically — against our existing user database to make sure a duplicate record is not being created.

Let’s start by creating the simple form shown below on a new page called Create profile screen. Send data from the user inputs to a Clipboard widget, naming the fields Name, Email and Date of Birth. After connecting a Submit Form action to the Submit button, create a new Decision chapter in your Directory and call it Email already exists in system? Drag the Decision to the canvas and chain it to the Submit Form action.

Create profile form

Before we build out the Decision, we need one other component in our Directory. Create a new datasheet and call it CUSTOMERS. Import the Person.csv file from the sample datasheets.

Now open the Decision. In its current state, the Decision canvas contains nothing but a diamond shape. The first things we’ll add are the data components that will supply the criteria for the Decision’s rules.

Drag a Clipboard widget from the Widget Toolbar to the canvas above and to the left of the Decision. Now drag the CUSTOMERS datasheet from the Directory panel to the canvas to the right of the Clipboard widget. Choose Get Record. Drag the Clipboard and release it on the Get CUSTOMERS widget, choosing ‘Add “Where” condition’ when prompted. In the Select a Field window, choose the ‘Email’ field and click OK.

Now drag the Get CUSTOMERS widget and release it on the Decision widget. In the Select a Record or Field window, choose ‘Record’ on the left, and then CUSTOMERS on the right. Click OK. At this point, your Decision will look like this:

The data side of a Decision

Now we can set up the Decision branches. Create a new page in your Directory called User already exists. Go back to the Decision and drag your new page to the canvas on the right side of the Decision widget. Drag the Decision widget to the Link widget to create navigation. This is your first branch.

For the second branch, we’ll start out by refreshing the Create profile screen. We’ll add more functionality later, but let’s keep it simple for now. Drag the Create profile screen from the Directory to the Decision canvas on the right side of the Decision widget. Drag the Decision widget to the new Link widget to create navigation.

Now that we have two branches, we need to define the rules that will determine the outcome of the Decision. Click in any empty area of the canvas or on the Decision widget itself to pull up the Decision’s Branches panel. In the Branches panel, click the Edit Rules link. Since we are evaluating whether or not a matching record exists in the datasheet, we’ll set the operator for the User already exists branch to ‘Is not empty’, and for the other branch to ‘Is empty’.

Decision rules

Open the Create profile screen and launch the page in your browser to test the Decision logic. First enter some random information into the three fields and click Submit. The page should refresh. Now toggle back to Studio and copy an email address from the CUSTOMERS datasheet. Back in your browser, paste the email address into the Email field and click Submit. The User already exists page should open.

Optional enhancement – capture a variable to control a dynamic display

Currently, when the Create profile screen refreshes, there is no indication that a profile was successfully created. Let’s remedy this by creating an alternate view of the form on the Create profile screen that is displayed only if the Decision follows the branch that refreshes this page.

On the Create profile screen, right-click the Form widget and choose Add View > Duplicate View. In the new view, delete the Submit button and replace it with a Text widget that says “Profile created!” Also add a new Button widget with the label “Next”.

Populate the user input widgets in the new view by sending data from the Clipboard, assigning the same fields that you created earlier. Since we haven’t actually created a new record in the CUSTOMERS datasheet yet, add a Save CUSTOMERS widget to the canvas and map the data flow from the user inputs. Finally, connect a Submit Form action to the Next button, and create navigation from the Submit Form action to a new page called Customer Dashboard.

Profile created!

Now we need to set a variable on the Clipboard to control the dynamic display on this page. We’ll do this in the Decision.

Back in the Decision, right-click the navigation line for the ‘Create profile screen’ branch and choose Insert Event > Clipboard. Select the resulting Clipboard widget, and in the Properties panel, type New user in the Data column, and Yes in the Value column. This assigns a value of Yes to a session variable called New user. In the Branches panel, fix the name of the second Branch (which changed to ‘Clipboard’ when you added the Clipboard widget) and click Edit Rules. You’ll see that the operator for the second rule needs to be changed back to ‘is empty’.

Now we can use the variable we just added to the Clipboard to control the dynamic display on the Create profile screen. Drag the existing Clipboard widget to the dynamic display. If prompted, choose ‘Set Views criterion’. In the Select a Record or Field window, choose the ‘New user’ field.

Open the Views panel and click the Edit Rules link. Leave the fourth column empty for the rule associated with the default view. For the other rule, type Yes in the fourth column.

Launch the page in your browser and test it by the same procedure we used earlier. Now if you submit the form without an email address that matches one in the datasheet, the alternate view will appear after the Decision executes. Clicking Next not only navigates to the Customer dashboard page, but also saves a new record to the datasheet.