Link question to pick it's ID automatically


(Abdul Bari ) #1

Hello all,
I have a challenge, In my form i have two questions school names and a school cods, wherewith i wanted to link school with its id, i mean when i am selecting school name the id automatically selected for that school, can you help me how to run this in ODK?

(Grzegorz Orczykowski) #2

Hi @Samim

How many items do you have? I mean different schools?

(Abdul Bari ) #3

Hi Grzesiek2010,
i have 60 different school names and 60 different school ids

(Moteb Marei) #4

Hi @Samim
Did you mean you to select the code or you want it to be selected automatically?
you can use choice filter and make it read only

(Grzegorz Orczykowski) #5

Then it would be a readOnly select question so the answer will be empty. Using choice_filter is possibly but the question should be marked as required rather.
The second option would be to create a long if-else statement but since you have 60 items it won't be easy.

(Abdul Bari ) #6

Hi Moteb,
i have 60 school names and for each school i have it's own id I wanted the id selected automatically since i am selecting school names how can i use choice filter can you give more clarification with some examples?

(Yaw Anokwa) #7

I don't think you need two questions here or choice_filters.

You can have a school select question where the name/value is the ID and the label is the school name. Then when a user selects the label and the ID is what is stored. Would that work, @Samim?

(Abdul Bari ) #8

Hi Grzesiek2010,
Could you please explain more or make it a little bit easy for me via some examples?

(Abdul Bari ) #9

I think it doesn't make sense, because I need to put them in drop down boxes i couldn't do this due i need to link it with SQL database after data collected. if you have any thoughts more then this i would appreciated.

(Yaw Anokwa) #10

If you do what I suggested with a select, then you can have a calculate question that uses jr:choice-name example that will also save the label.

(Abdul Bari ) #11

Hi aw Anokwa,
Could you explain more it think it's a good idea but still it's a little bit complicated for me i highly appreciated if you explain more here I am attaching school names and cods;
School Nname School Cods
Daykundi 200500001
Guzara 200500002
Karokh 200500059
Adraskan 200500060
when i am selecting Guzara school i wanted the ID 200500002 automatically selected.

(Yaw Anokwa) #12

Try this schools.xlsx (9.7 KB)

(Abdul Bari ) #13

Thanks for sharing this but it's not working, please see the attached snapshot.

(Grzegorz Orczykowski) #14

I tried the form provided by @yanokwa and it's ok, probably your edited version is buggy. What is the tool you use? The screenshot is not from Enketo right?

(Abdul Bari ) #15

I am using KoBo now it's working if i delete begin_repeat the only issue is with this i would appreciate if you support me for this, please see the screenshot

(Grzegorz Orczykowski) #16

Could you attach the form?

(Abdul Bari ) #17

sureF_1_M_database.xls (61.5 KB)

(Abdul Bari ) #18

When I am deploying the form to KoBo this error popped up, since i am deleting the begin repeat from the form then no error is popped up

(Grzegorz Orczykowski) #19

Please try just adding group name in row 21.

(Abdul Bari ) #20

Hi again i tried this many times it doesn't' work