Automatic generate code

Dear all,
May i kindly how to generate code automatically in kobo form.
Example.
Mother name- Aye Aye
Father name- Zaw Than
boy- 1
girl -2
DOB-2013
I want a code like this- AYZA113( AY mean mother name first two alphabet of first word, ZA mean father name first two alphabet of first word, 1 mean if boy, 2 mean if girl, 13 mean last two digit of 2013)
Regards,

Hi @ChrisNyi and welcome to the community!

This help article shows you how to achieve that:
https://support.kobotoolbox.org/unique_serial_numbers.html#approach-2-creating-unique-serial-numbers-from-selected-variables

Since your request needs the format-date option too, you can use the following.

Please note that because the name of the boy and girl is 1 and 2 in the choices I can simply add them to the concat function.

This is the survey sheet:

type name label calculation
text Q1 Mother Name
text Q2 Father Name
select_one A3 Q3 Gender
date Q4 DOB
calculate Q1_C substr(${Q1}, 0, 2)
calculate Q2_C substr(${Q2}, 0, 2)
calculate Q4_C format-date(${Q4}, ‘%y’)
calculate ID concat(${Q1_C}, ${Q2_C}, ${Q3}, ${Q4_C})
note note_ID Your Unique ID for this form is: ${ID}

And this is the choices sheet:

list_name name label
A3 1 Boy
A3 2 Girl
2 Likes

@hakan_cetinkaya, :clap: :heart: :partying_face:

1 Like

This solution is very helpful for me. Thank you hakan. I have additional details for DOB. For DOB, only count 2 digits( example 2014… just count 14).
Regards

1 Like

Hi @ChrisNyi;

This calculation should only take 2 digits:

format-date(${Q4}, ‘%y’)

Did you tried it yourself and find something different?

1 Like

Please accept my apologies… My typo error I used captial Y wrongly.
Thanks you so much.

2 Likes

@hakan_cetinkaya, :clap: :heart: :partying_face: