Pre-fill Enketo form using URL with ID generated in another form


I am trying to prepopulate a field in one form based on the ID generated in another form.

I use the concat function to calculate an ID based on the timestamp:

concat(substr(now(), 0, 4),substr(now(), 5, 7),substr(now(), 8, 10),substr(now(), 11, 13),substr(now(), 14, 16),substr(now(), 17, 19))

I then want to include this ID in a note with a hyperlink to open a new form with the ID field pre-filled.

The ID for this interview is ${ID} Please capture the contact details by clicking on the [link] (URL+?d[contact_id]=${ID})

However, the reference to the ID field is causing the link formatting to break:


I can show the URL correctly as plain text by not wrapping it in the hyperlink formatting:

The ID for this interview is ${ID} Please capture the contact details by clicking on the link: URL+?d[contact_id]=${ID}

Does anyone know how to make this work?

Welcome to the community, @bo_hurkmans! Maybe share the sample XLSForm with the community so that the community should also be able to help you out?

Thanks Kal_Lam!

The form can be found here.

Maybe instead of only calculating the ID, calculate the complete URL and then use [link](${url})

Thanks Nelson, that is a good idea!

I tried it, but unfortunately the URL still comes out wrong.


I have updated the sample XLS form to show how I did it.

@bo_hurkmans it actually works on Collect, turns out is an issue with Enketo
Here’s the form applying the workaround mentioned in the issue on github.
Sample XLS form url link.xlsx (22.4 KB)

Dank je wel Nelson, this is perfect!

So from what I understand, the correct way to do this is:

type: text
appearance: url

1 Like