Preselect a choice of select_one type

I have an xlsform (used in ODK collect) with a select_one field, which is populated automatically based on a choice_filter. This value has to be read_only.

I am trying to find a way to select by default the option (preselected). Is it possible?
Alternatively, I can set the read_only to "no". But this would add one extra step for the data collectors.

Hi @dkarakostis

It should be possible using calculation but you didn't attach your form so can't be sure. Could you do that? Ideally a small form that shows your problem if the original one is big or contains private data.

@Grzesiek2010 I attach a part of the form. The select_one field which I am referring is in the line 11 of the xls form.

Thank you.
SMPMS_20190726_0220.xls (59.5 KB) MyCom.csv (284 Bytes)

Hello,
You can even do both, like for CommodityNameApples
calculation: '345' and read_only: true (or yes).

Side-note: If the user doesn't need the code, you might also use a variable of type hidden. Disadvantage, no labeling (and not in print-out and report, but in dataset & tables).

1 Like

Hello @wroos, @Grzesiek2010, @dkarakostis

Im not totaly clear , can you help me with this xlsform (a simple example).
The objetive is select by default the option preselected using choice_filter.
How to express the calculate?.
Link in ENKETO
Example xlsx:example_choice_automatic.xlsx (30.4 KB)
image
Thanks.

@famador
why do you have duplicated options in all sets:
image
what do you want to achieve?

Hello @Grzesiek2010.

The example do not have all options, but in the archive that i share all codes have the same actividad(Cosecha Mecanizada). The codes are machine codes, all machine used to the same activity.
So the objetive in this example is the automatic select of options , to delete the manual select:

So after adding answer to the first question Código de equipo you want to populate the rest 5 questions with one matching option and make it selected automatically? Do I understand it correctly?

Hello @Grzesiek2010.

Yes that's right , the matching option is functional, only automatic selection is missing.

You can use calculation to select options automatically. Please take a look how I did it for your first question as a sample:
example_choice_automatic (3).xlsx (12.4 KB)

Hello @Grzesiek2010 , I have tried the example that you shared with me, but in this way I would have to create a conditional for each option.

Then I tried another solution that was working without problem.

Now with the new update of ODK Collect (V2021.2.4) I get an error
this one:
image

Have a idea to resolve that (in enketo work good(web) ).


If I remove the appearance option (minimal autocomplete) it stops showing the error, but in the next select one "variedad" field it fails again.

Could you upload your xls file? I guess you should use trigger but I can't be sure since I don't see your whole form.