Custom-made Unique ID

Hi All,

I understand CommCare creates a unique ID for each case once those are
created. However, its length and complexity constraint data analysis.
I would like to create a custom made unique ID by combining various part of
data collected.

An example could be the ID "SA17AG146" built as following:

  • SA17: group name
  • AG: Initial letter of the name and surname
  • 146: last three digits of the phone numbers

These are all information captured in the form but must be extracted to
create the ID, would it be possible?

Thank you very much.

Bests,

Alberto Gualtieri
MEL Officer at SaveAct, www.saveact.org.za
Pietermaritzburg, South Afria

Hi Alberto,

Yes, this is possible by creating a hidden value in the form, let's call it
'custom_id', and then saving this value to the case. To create the custom
id as described, you'll need to use 2 commcare functions outlined here -
substr
https://wiki.commcarehq.org/display/commcarepublic/CommCare+Functions?__hstc=240960668.8afbc7d499448a6897c272cb6b5db331.1457016010111.1489662521610.1490197701451.327&__hssc=240960668.2.1490197701451&__hsfp=1848929503#CommCareFunctions-substr
and concat.
https://wiki.commcarehq.org/display/commcarepublic/CommCare+Functions?__hstc=240960668.8afbc7d499448a6897c272cb6b5db331.1457016010111.1489662521610.1490197701451.327&__hssc=240960668.2.1490197701451&__hsfp=1848929503#CommCareFunctions-concat
So
your condition inside custom_id will look something like this below. Note
phone number expression example is based on 10 digits, like in SA:

concat(/data/group_name, substr(/data/first_name, 0, 1),
substr(/data/surname, 0, 1), substr(/data/phone_number, 7, 10))

Best,

Lauren

Lauren N. Fox
Dimagi, Inc.
RPCV Mozambique '07-'11

RSA: +27 (0) 81 831 4290
Moz: +258 82 78 49 245
dimagi.com http://www.dimagi.com/ *| *commcarehq.org

··· On Wed, Mar 22, 2017 at 1:16 PM, Alberto Gualtieri wrote:

Hi All,

I understand CommCare creates a unique ID for each case once those are
created. However, its length and complexity constraint data analysis.
I would like to create a custom made unique ID by combining various part
of data collected.

An example could be the ID "SA17AG146" built as following:

  • SA17: group name
  • AG: Initial letter of the name and surname
  • 146: last three digits of the phone numbers

These are all information captured in the form but must be extracted to
create the ID, would it be possible?

Thank you very much.

Bests,

Alberto Gualtieri
MEL Officer at SaveAct, www.saveact.org.za
Pietermaritzburg, South Afria

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dear Lauren,

It works perfectly, thank you very much!

Yours,

··· On Wed, Mar 22, 2017 at 6:14 PM, Lauren Fox wrote:

Hi Alberto,

Yes, this is possible by creating a hidden value in the form, let's call
it 'custom_id', and then saving this value to the case. To create the
custom id as described, you'll need to use 2 commcare functions outlined
here - substr
https://wiki.commcarehq.org/display/commcarepublic/CommCare+Functions?__hstc=240960668.8afbc7d499448a6897c272cb6b5db331.1457016010111.1489662521610.1490197701451.327&__hssc=240960668.2.1490197701451&__hsfp=1848929503#CommCareFunctions-substr
and concat.
https://wiki.commcarehq.org/display/commcarepublic/CommCare+Functions?__hstc=240960668.8afbc7d499448a6897c272cb6b5db331.1457016010111.1489662521610.1490197701451.327&__hssc=240960668.2.1490197701451&__hsfp=1848929503#CommCareFunctions-concat So
your condition inside custom_id will look something like this below. Note
phone number expression example is based on 10 digits, like in SA:

concat(/data/group_name, substr(/data/first_name, 0, 1),
substr(/data/surname, 0, 1), substr(/data/phone_number, 7, 10))

Best,

Lauren

Lauren N. Fox
Dimagi, Inc.
RPCV Mozambique '07-'11

RSA: +27 (0) 81 831 4290
Moz: +258 82 78 49 245
dimagi.com http://www.dimagi.com/ *| *commcarehq.org

On Wed, Mar 22, 2017 at 1:16 PM, Alberto Gualtieri koderrimo@gmail.com wrote:

Hi All,

I understand CommCare creates a unique ID for each case once those are
created. However, its length and complexity constraint data analysis.
I would like to create a custom made unique ID by combining various part
of data collected.

An example could be the ID "SA17AG146" built as following:

  • SA17: group name
  • AG: Initial letter of the name and surname
  • 146: last three digits of the phone numbers

These are all information captured in the form but must be extracted to
create the ID, would it be possible?

Thank you very much.

Bests,

Alberto Gualtieri
MEL Officer at SaveAct, www.saveact.org.za
Pietermaritzburg, South Afria

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the
Google Groups "commcare-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/commcare-users/kw7NVOGW4D4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Alberto Gualtieri
United Nations University - MERIT
Master of Public Policy and Human Development, 2016
ITA +393389164740