Default value for row in matrix question

Is it possible to set default value for matrix question in form? If yes - how?


Yes it should be possible, but you’d have to edit the resulting XLSForm manually - there’s no mechanism to specify per-cell default values in the current Kobo formbuilder UI.

If you look at my earlier forum posting about matrices you can see how these cells actually end up being represented in the resulting form; you should be able to (manually) add a value to their respective default column where desired.

Thanks for reply! Thats some hint. Is it possible by API?
I can make mechanizm to fetch XML (if there is one), add those values and save with XML.
But my main usecase is create/fill those fields without touching kobo configuration.

Or maybe you know some other way to create form with such shape:
Let’s say I have 3 products in my application - Apple, Banana, Pineapple.
In my application ppl provides amount and units, example:
Apple - 5 pieces
Banana - 2 kgs
Pineapple - 4 pieces

I would like to ask for additional info - for this example let’s say I want to buy it so I would like to ask in shop if it’s available and what’s the price.
So as I see it - I create a matrix question with columns - Quantity, Unit, Price, Availability.
In row I have Apple, Banana, Pineapple.
I would like to fill Quantity and Unit since values for them are coming from other source.

Is it even possible?

Short answer… nope. There is no mechanism via the Kobo KPI formbuilder GUI to specify per-cell default values, nor is there a Kobo API to set specific attributes of specific questions of specific forms.

Basically, the KPI formbuilder is a (very) nice GUI abstraction for constructing XLSForms. XLSForms in turn is a (very) nice abstraction for constructing XForms [which is what KoboCollect, ODK Collect, Enketo, et al, actually consume]. And with all abstractions, you must trade-off some degree of functionality for the sake of convenience/usability. So if you need to tweak this level of granularity - ie setting default responses in matrrix questions - you will have to drop down a level of abstraction and start fiddling with XLSForms directly, outside of Kobo per se.

If a requirement is to remain entirely within the scope of what the Kobo formbuilder provides, then I dont believe there is any way to accomplish this. However, it may be possible with a custom-written XLSForm.

Again thanks @Xiphware for the reply!

Maybe you know if there are any examples of custom written XLSForm, or how can I see how my current one looks like in XLSForm to create a parser from JSON to XLSForm.

Also how such form can be deployed? Currently I can use PATCH on resource giving some “content”. It will look the same or there are other methods/urls for that?


I’m a bit confused now… is yours a form you have written in Kobo, or an XLSForm, or an JSON (ODK Build?) form, or a raw XML form that you wrote by hand?

Firstly I created it manually - in koboforms - by GUI.
By requests I tracked how data is passed and I have created a parser in NodeJS that creates such form template in JSON, then Im using library to make it form data that can be passed to Koboforms via API.

What client are you intending to deploy these forms to for data capture: eg Enketo webforms only, or KoboCollect and/or ODK Collect too? This matrix stuff only works with Kobo webforms - there’s no support for any of this matrix in ODK Collect yet (or its derivatives AFAIK). Although you be interested in following this ODK feature request:

I’m using KoboCat Enketo