Welcome to the ODK forum, @Amr ! We're glad you're here. When you get a chance, please introduce yourself on this other forum thread . I'd also encourage you to add a real picture as your avatar because it helps build community!
For KoBo Toolbox specific issues you'll need to ask at https://www.kobotoolbox.org/#help
I didn't have time to look at this in detail. But some useful links about doing this in ODK might be:
getodk:master
← cooperka:autofill
opened 06:08PM - 15 Feb 19 UTC
Closes https://github.com/opendatakit/roadmap/issues/30
~~Depends on https://… github.com/opendatakit/javarosa/pull/406~~ (merged and snapshotted)
Allows form designers to refer to the last-saved instance of this particular form in order to retrieve answers from it. Currently intended for text-based answers rather than media. Simply add an external instance to your form:
```xml
<instance id="last-saved" src="jr://instance/last-saved"/>
```
The instance `id` can be anything you want.
Then you can access the external data as usual, for example:
```xml
<setvalue event="xforms-ready" ref="/data/foo" value="instance('last-saved')/data/foo"/>
```
⚠️ `xforms-ready ` is being deprecated, see [here](https://forum.opendatakit.org/t/spec-proposal-add-first-load-event-to-replace-xforms-ready/18662/15) for more info. TL;DR: Use `odk-model-first-load` now instead.
#### What has been done to verify that this works as intended?
Extensive testing with [modified All Widgets.xml](https://github.com/opendatakit/collect/files/3014222/All.widgets_save.xml.txt): filling blank forms, saving forms, filling new blank forms, finalizing, exiting without saving, etc.
Addtional testing with encryption to verify `last-saved.xml` is deleted when the form is finalized. Valid sample encryption key you can test with:
```xml
<submission base64RsaPublicKey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnTXfMaLqcrbxgCA3T2bg4RcugjW8EjuyLttzIGsqX1wcazHLMwW8iGGREfMIM22M1MiRE5+1EygNG+rz2MR1o1YjPyULgzi38KFyLkPJ96lq23kCMzh1wPrXRE7Hhu3C/eojc33RNtT2g9xpwPRAaY1v+X+Fypsq4GckMKNLfrQIDAQAB"/>
```
#### Why is this the best possible solution? Were any other approaches considered?
See extensive discussion at https://github.com/opendatakit/roadmap/issues/30. The result of the discussion there was this approach. It makes use of existing logic to accomplish this feature without needing too much new code.
Collect caches the last-saved instance to the form's media directory `formName-media/last-saved.xml` on each save. This file will stay around even if the original saved instance is lost, which is probably what users would expect. The form's media directory is deleted when the blank form is deleted from the device, which is also probably what users would expect.
When parsing new FormDefs, `lastSavedSrc` will be passed to JavaRosa as either `"jr://file/last-saved.xml"` or `null` if no file exists because the form has never been saved. A `null` value means no instance `src` is provided, meaning the instance will be treated as **internal** instead of **external**. The internal `<instance id="last-saved"/>` has no children and thus will provide empty values for anything referring to it.
#### How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Form designers will be able to designate questions as "auto-filled" based on the last-saved value for that particular question. I don't anticipate much regression risk here since the old logic isn't significantly modified.
#### Do we need any specific form for testing your changes? If so, please attach one.
Linked above.
#### Does this change require updates to documentation? If so, please file an issue [here]( https://github.com/opendatakit/docs/issues/new) and include the link below.
Yes [TODO file issue].
It will also require an update to ODK Build if they want to support this [TODO file issue].
#### Before submitting this PR, please make sure you have:
- [x] run `./gradlew checkAll` and confirmed all checks still pass OR confirm CircleCI build passes and run `./gradlew connectedDebugAndroidTest` locally.
- [x] verified that any code or assets from external sources are properly credited in comments and/or in the [about file](https://github.com/opendatakit/collect/blob/master/collect_app/src/main/assets/open_source_licenses.html).
- [x] verified that any new UI elements use theme colors. [UI Components Style guidelines](https://github.com/opendatakit/collect/blob/master/CONTRIBUTING.md#ui-components-style-guidelines)
and
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 su…