Offline caching when using default values deep links

We are using a mini-app to support repeat visit, longitudinal user tracking. The mini-app forms a URL to jump over to Kobotoolbox Entenko with default values preset. We prefill 8 separate values. The following example shows our URL format with just 1 value shown to demonstrate:

https://ee.kobotoolbox.org/x/KXXXXXXl/?&d[User_ID_Number]=22223

As with a blank form URL, it works well when offline when we precache it and then use the exact same URL. However, when we are offline and attempt to load an adjusted URL (new User ID),

https://ee.kobotoolbox.org/x/KXXXXXXl/?&d[User_ID_Number]=22224

we get the standard error: This site can’t be reached. The web page at https://ee.kobotoolbox.org/x/KXXXXXl/?&d[User_ID_Number]=22224 might be temporarily down or it may have moved permanently to a new web address. ERR_FAILED

I’m guessing this is because the browser mistakenly thinks it is an entirely new site and the offline caching doesn’t kick in. Is there a work around to this issue or must we pick between offline OR default values?

I think your diagnosis is right, but I wonder if the defaults could be communicated in a URL fragment (beginning with #) instead the query string to avoid (hopefully) triggering an attempt at network communication. This would require some development work on Enketo Express, but maybe it’s possible now that Enketo no longer uses # for a different purpose in its offline URL scheme.

I’ll ping @martijnr to see if he has time to debunk my idea quickly, or, if he’s too busy to respond, you could try posting on Redirecting to Google Groups.

1 Like

I think the issue is that we haven’t added support for such defaults in offline views (see https://apidocs.enketo.org/v2#/post-survey-offline). Historically, this was technically not feasible to do, but now (with the new type of caching), it could be. There is no plan to implement this but a PR would be welcome.

What would be supported currently, is to serve a dynamically generated external XML (or CSV) file, and use the new (XLSForm) dynamic defaults feature to populate default values from that file.

1 Like

Thanks for the input. It doesn’t seem like it will be possible to link these apps together at present for both offline and defaults since the mini-app source cannot generate more than a (dynamic) URL. Or maybe I’m not understanding @martijnr suggestion for dynamic forms?

Something like the following (borrowed from another app deep link format) would be ideal:

https://ee.kobotoolbox.org/x/KXXXXXXl/#defaults={"User_ID_Number"="22224"}

If this seems worth making a feature request, where would I submit a request like that?

If you’re using a non-custom KoBoToolbox server, the idea of using a dynamic external data file will not work.

Feature requests could go here: https://github.com/enketo/enketo-express/

I’ve already created it for you: https://github.com/enketo/enketo-express/issues/228 (but note that we’d still need somebody to contribute this feature as I probably won’t do it myself soon).

P.S. Enketo is using # fragment identifiers for something else, i.e. to go directly to a specific question.

1 Like