Since its inception, Calcapp has allowed you define a hierarchy of screens reachable by your users. List screens enable users to select an option (now known as a navigator) and be brought forward to the screen associated with the navigator. Form and text screens enable users to move forward to a single pre-determined screen by pressing Next in the upper-right corner.
Up until now, that hierarchy has been fixed and unchangeable, with no room for making decisions based on formulas. In particular, it has not been possible for multiple screens or navigators to send the user to the same screen, where this screen can take the selection made by the user into account.
This property enables you to do things like send the user to a warning screen if the information filled out by the user does not check out. You can also take a user straight to a results screen if you so choose, or ask for additional information before sending the user to the results screen, all based on formulas.
To send a user to a screen named Screen1, simply associate the following formula with a NextScreen property:
To send a user to Screen1 if Field1 is valid, and to Screen2 otherwise, use this formula:
(Returning a blank value from a NextScreen property does not prevent the user from moving forward. Rather, it makes Calcapp use the screen which naturally follows the screen, which you have set in Calcapp Creator.)
Using a drop-down field as a list screen
Up until now, list screens and drop-down fields have had very little in common. List screens and their navigators have sent users forward to pre-defined screens, whereas the selection made from a drop-down field has not had any influence on the screen shown to the user as they move forward.
The NextScreen property changes all that. Let’s say you have a text drop-down field named ScreenSelection with the options “First screen,” “Second screen” and “Third screen.” To move the user forward to Screen1 if “First screen” is selected, to Screen2 if “Second screen” is selected and to Screen3 if “Third screen” is selected, use this formula:
Using a list screen as a drop-down field
Sometimes, you don’t want a list screen to determine what screen is shown next, you want the same screen to be shown regardless of what list screen navigator is chosen. You then want this screen to take into account the selection made by the user.
Achieving the first requirement is easy. Simply associate a formula with the NextScreen property of all navigators of the list screen—let’s say it’s named ProductChoice—and have the formula reference the same screen, named ResultsScreen:
The second requirement asks that we have a way of learning what navigator was selected. This is achieved using a new read-only property of list screens, ActiveNavigator.
To make the title of the next screen reflect the choice made by the user, associate this formula with the Label property of the screen:
The ActiveNavigator property of ProductChoice returns the navigator the user selected. In turn, this navigator has properties of its own that we can access, including Label, reflecting the label of the navigator. (You can associate a formula with the Label property to determine it dynamically.)
You can use the XLOOKUP function to look up a value associated with the selection made by the user. Consider this formula:
The formula above returns the price of the product represented by the navigator activated by the user. XLOOKUP expects its first parameter to be the value to find in the array given as the second parameter. If found, the array element at the same position in the array given as the third parameter is returned. Here, the value to find is the label of the navigator activated by the user, which is expected to be either “Product A”, “Product B” or “Product C”.
This SWITCH formula is equivalent:
Linking navigators to the same screen versus copying and pasting
In the past, many app authors wanted to achieve the effect described above, that is, multiple navigators all leading to the same screen, with this screen taking the selection into account. This was achievable by liberal use of copy and paste.
If a list screen consisted of 20 navigators, app authors would copy a single screen and paste it 19 times, associating the copies with the other navigators. To make these screens reflect the selection made by the user, authors would make small modifications to each screen copy.
There are several disadvantages to this approach. From an app author’s perspective, making changes to the duplicated screens becomes an arduous process, with each change having to be made multiple times. From Calcapp’s perspective, having screens (and the screens following them) be duplicated many times makes apps very large, which may make them run sluggishly or not at all.
By linking several navigators to the same screen, you reap all the rewards of copying and pasting screens with none of the disadvantages, provided that the screens you would have copied and pasted differ little from one another.