Send people somewhere after a form is submitted
Choose where the app goes next, with links that depend on the case and the person.
When a form is submitted, the app has to go somewhere. Often the right place depends on what was just saved: a screening that found a risk should open the referral form, a visit that closed the case should go back to the list, and everything else should return to the module.
After submit is where a form says that. It holds a short list of destinations, each a form or a module to open and, if you like, the condition it runs under, and an Otherwise row that says where the form goes when no destination with a condition or a carried case runs.
Where to find it
Open a form, choose the settings gear, and find After submit. With no destinations yet, the row says where the form goes and offers the built-in destinations, Another form or module, and Add destinations. Once a destination exists it says what runs, such as Runs 2 destinations in order, with the form's Otherwise beside it, and offers Edit destinations.
The After submit screen has its own address, so you can link a teammate straight to it. The Preview control runs the form the links belong to, and Preview runs the destinations the same way the app does.
The order matters
The list is headed After this form, these run in order. Every destination whose condition is true runs, from the top down: on Android the next one opens when the worker finishes the one before it, and in Web Apps only the first one that applies opens. Each row says when it runs: Every time, When its condition is true, and, for a destination that carries a case, When the case it carries is on the worker's device. Two destinations can both apply at the same time, so order is part of what you are saying.
Add one with Go somewhere every time or Go somewhere when a condition is true. Drag a destination by its handle, or focus the handle and use the arrow keys (Home and End jump to the ends). Any destination can go in any position.
Otherwise
The Otherwise row is always last. It is where the form goes when no destination with a condition or a carried case runs, and it shows once a destination has one. It opens before a destination that runs every time. Otherwise, go somewhere else sets it, and until a destination has a condition the builder says Give a destination a condition first, so there is a time when none runs.
With no Otherwise, the app goes home when no destination runs, and the row reads Otherwise, back to the app home. The same choices say where a form with no destinations goes:
- App home: back to the main screen. On Android that is the app's home screen; in Web Apps it is the app's first screen, which lists its modules. For the Otherwise it is The app home, which leaves the form without one.
- First menu: the app's first menu, which lists its modules. In Web Apps this is the same screen as App home; on Android, App home opens the home screen and First menu opens that list.
- This module: open the module at its normal starting screen.
- Parent module: for a form in a submenu, open the module above it, with the case it selected still selected.
- Previous screen: return to the preceding selection or task. When the form was chosen before its record, its record picker opens again for that same form. When the record was chosen before the form, the module menu opens with that record still selected. This follows the app's task sequence.
- Another form or module: open a form, or a module's form list. For a form with no destinations it opens the destinations screen, where you add one; for the Otherwise it is a link of its own.
When a form gains its first destination with a condition, where it went after submit becomes its Otherwise, and Nova says so. When every destination runs each time again, the Otherwise has nothing left to cover, so Nova removes it and tells you.
Which destinations a form is offered
The list only offers destinations the form's module can return to, so a choice you see is one CommCare can build:
- Previous screen isn't offered in a module that selects several cases, under a module that does, or in a menu whose forms read the search. The usual destination there is This module, or First menu under a module that selects several cases.
- This module isn't offered under a module that selects several cases.
- Parent module is offered only to a form in a submenu, and not while the module above it selects several cases.
- A form in a module that is off the menu isn't offered its own module or the previous screen, and a form isn't offered the module above it while that module is off the menu. Its forms go to First menu instead. See Display conditions for what "off the menu" means.
Module isn't offered in a menu that shows its forms in the menu above, and Parent menu isn't offered under one, because neither has a screen of its own. Previous screen can reopen the case picker for a form on the first menu. If those forms all start with the same case selection, it returns to the first menu. On Android the next form that asks for that selection opens with the chosen case. In Web Apps people choose again. A link to a form on the first menu carries its record the same way. A submenu can return to Module when the submitted form supplies the record its parent menu needs.
When a change to a module takes a destination away from one of its forms, Nova moves the form to the nearest one still offered and tells you.
What a condition can read
A link's condition runs after the form has closed. That decides what it can use:
- The case the form just saved, including the values this very submission wrote to it. A link on a visit form can read the status the visit just set, and a link on a registration form can read the case it just created.
- The person using the app: their worker information.
- Project data and places: a row of a data table, or a place in your organization.
- What a search found, when the form opened in a menu whose forms read the search, such as how many cases it returned.
It cannot read the form's answers, because by the time the link runs the form is gone. If a link should depend on something someone typed, save that answer to a case property and read the property instead. The condition editor only offers what a link can use, and says so when you reach for a form answer.
Carry values
Some destinations open straight away. Others open a case, and need to know which one. The link's detail screen shows what its destination needs:
- When this form opened or created a case of the right type, the link carries it automatically: Carry it automatically says which case travels with the person.
- When it cannot, choose Work it out here and give the case id the destination should open. The screen lists every value the destination needs; a link carries all of them or none of them, so there is no half-filled handover.
- A destination whose forms read the search needs to fetch the carried case before it opens. Carry it automatically supports the case this form selected or created. An explicit assignment to that same case works too. A different manual assignment may be unavailable; Nova names the link and offers automatic matching or a destination whose forms read their own case, which supports manual values.
- A destination that carries a case runs only when the worker's device holds that case. A value that names no case of that type never opens the destination; the next one, or the form's Otherwise, runs instead.
- A module's form list needs nothing carried: the person picks a case when they arrive. A link to a module carries no values.
Start this form again
Start this form again is the first choice in the destination picker. It opens a fresh copy of the same form, which suits a form workers fill in many times in a row. It keeps working if the form moves to another module. A destination can also open a form whose own destinations lead back here.
What Nova refuses
Nova keeps the list in a shape the app can run, and says why before anything changes:
- A link to a submenu CommCare HQ can't link to from this form's menu: choose the menu above it or a form inside it. A form can link to a submenu only from a submenu whose parent has the same case type, and the target picker says so beside each one it can't offer.
- A link whose destination needs a case this form cannot hand over. Carry the value by hand, or choose a destination this form can pass its case to.
- An Otherwise that could never run, because every destination runs each time. Give a destination a condition first.
- A link to a module that is off the menu. It would open a menu with nothing in it on Android and the app's first screen in Web Apps, so point the link at a form inside the module, or show the module on the menu again.
When the destination isn't on the menu
A link can point at a form someone can't see on their menu: a form that is off the menu, a form inside a module that is off the menu, or a form or module whose display condition is false for the person submitting. Android and Web Apps handle these differently:
- A form that is off the menu, or hidden by its display condition: Android opens it. Web Apps doesn't, and lands on the module that holds it, listing its other forms.
- A form inside a module that is off the menu: Android opens the form. Web Apps lands on the app's first screen.
- A module hidden by its display condition: Android opens it with nothing in it, and Web Apps opens the app's first screen instead.
The link's detail screen says this under a link whose destination some workers may not see. Preview does what the platform it runs as does, as the list above describes for each case.
On a device
On Android every destination that applies runs in order; in Web Apps the first does. The Otherwise runs when no destination with a condition or a carried case runs, and a carried case opens the destination directly. What you see in Preview is what the app does on the platform Preview runs as.