Remembering previously entered value in ODK Collect

The feature that @cooperka and @tomsmyth described in the roadmap is about to be released in Collect.

I'll try to summarize how I think of it and @cooperka/@tomsmyth, please jump in to correct and augment. The feature will make it possible to specify questions that should automatically be populated with the value that was in the filled form that was last saved. Here are some examples of what the feature enables:

  • use the feature for a "street" question in a form definition. The first time a surveyor opens the form, the street question's value will be blank. If the surveyor enters "Abbey Rd" as the street name and then saves the form, the next time the surveyor opens a blank form, the street question will have "Abbey Rd" set as the street name. The surveyor can then leave the street name as-is if he or she is still on the same street or change it if needed.
  • use the feature for a "earthquake date" question and questions in an "earthquake details" group in a form definition. The value of the last earthquake date saved and information about that earthquake is then available to other questions in the form. For example, a question could read "Would you like to enter data about the <value from last saved form> earthquake?" Based on that answer, a whole set of questions could be automatically populated or hidden.
  • use the feature for a "patient count" question in a form definition. The value of the last patient count saved could then be used to set the default. That is, the default value for "patient count" could be <value from last saved form> + 1.

These are just some examples of what can be done. The way to think of it is that any value from the last form that was saved can be pulled into the form design. This is deliberately the last filled form saved rather than the last filled form created because it means a user can open, review and save a form filled in the past to make it the "template" for the next new form created. For example, let's say I'm collecting data about natural disasters A and B. After I've filled one form about A, I can quickly fill out 10 more because when I open a blank form, the values about A will be pre-populated. Then, when I start filling out info about B, I can clear the defaults and fill out the info for B. If I then realize I need to fill out another form about A, I can open one of the original ones, save it, and then the next blank form I open will have values about A pre-populated.

(As a side note, @Xiphware, for the behavior to be consistent across clients, I would suggest that you keep track of the UUID of the row a value was last changed in and use the whole row as the last saved instance to be queried.)

The next step to make this easy to use is to agree on a way to use it in XLSForm. See XLSForm spec proposal: add syntax to make it easy to use a value from the last saved instance for that discussion.

For those interested in the implementation details, there's also a conversation about the event that will trigger populating the defaults at Spec proposal: add first-load event to replace xforms-ready.

There are several different takes on remembering previously entered values that have been discussed in this thread. Some of them are a version of Enable Case Management/Preloading but others are interesting ideas that could be explored further. If your needs were not met by the feature that is shipping soon, consider creating a new feature request.

As another side note, this feature makes it possible to query one specific saved filled form. One way to think about case management is the ability to query any saved filled form and share saved forms across surveyors.

5 Likes