Enketo public access link with prefilled fields

1. What is the issue? Please be detailed.
I'm self-hosting ODK Central (v1.5.3, just updated from master) and am trying to prefill fields in public access links.

versions:
da62679fe138eb89b42fcc2d9f61ae9beca9d67b (v1.5.3-2-gda62679)
 d9cb07fdceaa7df017ed2aee114db1b2b7e1a2d8 client (v1.5.3)
 badb3912fdf4d5dca29bd4cd520b9d3b4788db6e server (v1.5.3)

2. What steps can we take to reproduce this issue?
This works:

  • ODK Central > form > submissions > new > Enketo link (create a new submission in browser)
  • Append desired parameter to above link https://DOMAIN/-/HASH?d[request_id]=xxx prefills the question request_id to value xxx.

This doesn't work:

  • Create a public access link
  • Append ?d[request_id]=xxx to access link > redirects to ODK Central homepage.

Update: Append &d[request_id]=xxx to public access link (note the ampersand)
https://DOMAIN/-/single/HASH?st=TOKEN&d[request_id]=xxx

3. What have you tried to fix the issue?
Searched the docs, web, forum.

4. Upload any test forms or screenshots below.

The solution is that the public access link already contains request parameters and additional parameters need to be added with an &.

2 Likes

Because I just tripped over the same issue and a quick web search brought me back here, this is how prefilling fields within a group works:

Consider an XLSForm with a group grp_project which contains a field project_year.

start	start_date		
deviceid	device_id		
begin_group	grp_project	# Project details	
note	n_project_id	## Project ID	This section identifies the application it refers to.
integer	project_year	Project Year	Your application's project year
integer	project_number	Project Number	Your application's project number

The public access link to set project year to 2000 and project number to 3 will be

https://domain/-/single/xxx?st=xxx&d[grp_project/project_year]=2000&d[grp_project/project_number]=3
3 Likes