Prefill fields via URL in Enketo

Hello

I am trying to pre populate fields in a survey via a URL variable or query string.

So far I’ve found 2 articles regarding this but I’m still unable to do it neither in form hosted by kobo nor slfr ohsted in my servers.

https://help.ona.io/knowledge-base/how-do-i-prefill-form-fields-using-enketo-express/

I’ve tried this and similar with no luck to polulate data/visita_SPV field:

http://67.205.154.75:8001/admincapris&form_id=‘aa84ppstK5QtruwFkgZBDZ’&defaults[/data/visita_SPV]=6699

https://ee.kobotoolbox.org/::KdZG6c4D&form_id=aa84ppstK5QtruwFkgZBDZ&defaults[/data/visita_SPV]=6699

etc…

What am I doing wrong?

Thanks!

Hi,
Your syntax is wrong
Should be

https://ee.kobotoolbox.org/::KdZG6c4D/?&d[visita]=6699&d[text]=anytext

in order to fill a fiel called ‘visita’ with the value ‘6699’, and a field called ‘text’ with the value ‘anytext’

Regards

2 Likes

Hi @areyal
Welcome to the community forum. Thank you for your post and chiming in on this.

Stephane

I’m following the Syntax above, but I’m not seeming to get my fields to pre-populate? Is the pre-population invisible? Am I doing something wrong?

The :: disappears from the URL in front of form ID when I submit the URL

@knoxjohnny, you could do it as outlined in the image shared below by adding ?d[Q1]=Apple behind the survey URL. Note, Q1 is the variable name for the survey project shown in the example.

In the survey tab of your xlsform:

Image 1

Data entry as seen in Enketo:

Reference xlsform:

Enketo Prefill.xlsx (10.0 KB)

Hi @knoxjohnny
Do you mind sending your XLS form so that we can look at it? It seems that this name may be having an issue.
The hypothesis that I need to test:

  1. Use of an underscore in the name does not work with prefill ( testing approach; change the name to staffname)
  2. Prefill does not work with a long-form (testing approach; remove all other questions except that one and test)

Stephane

2 Likes

@Kal_Lam Yes I was using the Column Name. See here:

@stephanealoo
I will send the XLS in DM.

@stephanealoo I created a quick demo form to test your idea. and it looks like I was able to get information with combination of all your ideas: long test as well as _ in name… Loom | Free Screen & Video Recording Software

I have the same problem. The URL fill works in a test form but the same syntax does not work in the existing form that I need to change. Were you able to find a solution to this?

I found the source of the issue in my case. The existing form has sections, so rather than just passing the value to [country] I have to pass it to [intro/country].

Thank you for sharing this with the entire community, @naledi_h!

1 Like