I am currently using ODK and would like to request your support regarding an implementation issue.
After updating and uploading the form to the ODK server, the form does not work correctly in ODK, although it works in Kobo. I didn’t change any logic or calculations in the survey sheet; I only added new villages in the choices sheet.
The issue is related to the auto-generated Family Member ID. In ODK, the last two digits of the ID always remain “00” for all respondents, whereas it should start from “01” for the first family member and increase sequentially. This process can be seen in the attached ODK screenshot. When tested in Kobo, the ID is generated correctly, as shown in the Kobo screenshot.
I also tried re-uploading the previous form version to the ODK server, downloaded it to the tablets, and tested it offline. However, the same issue in ODK.
Could this problem be related to the ODK server or a server update during upload? I would appreciate your guidance on how to resolve this issue.
begin_group
eligible
eligible
Eligible HH
${int_result}=1
integer
total_family
Total Family Number
မိသားစုဝင် အရေအတွက် စုစုပေါင်း
yes
. >0 and . <20
begin_repeat
family_info
### Family Information
### မိသားစုဝင်နှင့် သက်ဆိုင်သော အကြောင်းအရာ
${total_family}
begin_group
family_member
Family Member
Family Member
begin_group
basic_info
Basic Info
မိသားစု အချက်အလက်များ
field-list
calculate
position
_Family Member Number_
_မိသားစုဝင် အမှတ်စဉ်_
at least 2 digits (01)
ဂဏန်းအရေအတွက် ၂ လုံးဖြည့်ပေးရန်။ (ဥပမာ- 01)
yes
0
.>=01 and .<=${total_family}
Family Member Number should be exceed total_family number
Thank you very much for taking the time to help and for your support. I’ve attached a screenshot and marked the arrow area where the issue occurs. Please kindly take a look.
I checked on the v2025.3.3 and I was not able to reproduce it.
Is it possible for you to attach the form? This would make it easier to identify the problem.
If not, you can try recording a video showing how you are getting the incorrect data.
Thank you for checking this on v2025.3.3.
As shown in the image shared above, the ID indicated by the arrow is expected to increase by one for each entry, based on the number of family members. However, it is still not incrementing as expected.
I would like to kindly inform you that I have also updated the calculation to the following syntax; however, the issue persists and the ID does not increment:
if(
${total_family} > 0 and ${total_family} <= 20,
concat(
${hhid},
'-',
if(position() < 10,
concat('0', string(position())),
string(position())
)
),
''
)
I have uploaded the recording video you requested, which demonstrates the issue occurring during data entry in the ODK Collect app.
The calculation used in the form is exactly as shown above, and I have also attached the form for your reference, which I hope will help in identifying the issue.
Thank you very much for your understanding and continued support.
Kind regards,
One thing that jumps out at me in what you just shared is position(). This would be the position of the fam_id which is always 1 because it is not repeated. What you likely want is the position of the containing repeat so position(..). The .. means "go up to the container that this form field is in". So position(..) is "give me the position of the repeat that this question is inside."
What you originally shared included position(${family_info}) which should also work.
If you change the position calls to position(..), do you get the behavior you expect?
I would like to sincerely thank you very much for your guidance regarding the calculation and use of position() in the family member ID logic. I have applied your suggestion, and the fam_id now increments correctly for each family member.
Here's the code that I implemented based on your advice:
integer total_family Total Family Number မိသားစုဝင် အရေအတွက် စုစုပေါင်း yes .>0 and .<20
begin_repeat family_info ### Family Information ### မိသားစုဝင်နှင့် သက်ဆိုင်သော အကြောင်းအရာ ${total_family}
begin_group family_member Family Member Family Member
begin_group basic_info Basic Info မိသားစု အချက်အလက်များ field-list
calculate fam_no Family Member Number မိသားစုဝင် အမှတ်စဉ် at least 2 digits (01) yes 0 .>=1 and .<=${total_family} Family member number should not exceed total family number position(../../..)
calculate fam_id Family Member ID Family Member ID if( ${total_family} > 0 and ${total_family} <= 20, concat( ${hhid}, '-', if( string-length(string(position(../../..))) = 1, concat('0', string(position(../../..))), string(position(../../..)) ) ), 'check family number' )
note fam_id_note Family Member ID: ${fam_id} Family Member ID: ${fam_id} yes
Your explanation was helpful and I really appreciate your help!
Thank you everyone for kindly guidance and support!
Best regards,