Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch forms via odkcollect:// links, with entity preselection #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

zestyping
Copy link
Collaborator

@zestyping zestyping commented Mar 17, 2024

This proof of concept enables the use of a browsable link to launch the FormFillingActivity on a specific form. A query parameter in the link can also preselect an entity in the form.

The implementation consists of three parts:

  1. Add an <intent-filter> to the manifest entry for FormFillingActivity, which catches URLs that begin with odkcollect://form/

  2. Add a branch in the FormLoaderTask that handles an incoming intent with this kind of URL by looking up a specific form by its Form ID (e.g. "trees_follow_up") rather than its internal id (e.g. "forms/2").

  3. Add a method preselectEntity that pre-answers a question in the form, according to a query parameter in the URL. The parameter name should match the name of the question, and the parameter value should be the UUID of the entity.

With these changes, a webpage with a link such as the following will launch ODK Collect into the form filling flow, for a specific form, with an entity preselected:

Launch a form:
<a href="odkcollect://form/trees_follow_up?tree=71297c7d-6a22-4354-b08a-3fbee155d74e">
  trees_follow_up
</a>

For testing, the above HTML is available here so you can load it on a phone browser: https://zestyping.github.io/odkform

…ollect://form/<form-id>", allowing an entity to be preselected with a query parameter.
@spwoodcock
Copy link
Member

spwoodcock commented May 24, 2024

Selecting the feature via the intent works perfectly.

I need to investigate further next week, but the form id in the intent URL seems to be causing an error on form submission hotosm/fmtm#1538

Perhaps the value of the form id is being injected somewhere it shouldn't be? When the form is submitted, the error is displayed: Sorry, form save failed! For input string: "x_form_id_here"

@spwoodcock
Copy link
Member

spwoodcock commented Jun 7, 2024

@spwoodcock
Copy link
Member

spwoodcock commented Aug 26, 2024

I think something went wrong with the rebase: if it helps I can reset this to it's original state?

Let me know! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants