# Creating id in xlsform

**URL:** <https://forum.getodk.org/t/creating-id-in-xlsform/4328>\
**Category:** Support\
**Created:** [May 13, 2015, 2:42pm UTC](https://forum.getodk.org/t/creating-id-in-xlsform/4328 "2015-05-13T14:42:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mercy\_Adams](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@Mercy\_Adams](https://forum.getodk.org/u/Mercy_Adams)\
**Post date:** [May 13, 2015, 2:42pm UTC](https://forum.getodk.org/t/creating-id-in-xlsform/4328/1 "2015-05-13T14:42:06Z")

</div>

how can I create an id for data or records in xlsform.

---

<div class="post-metadata">

**Author:** ![Mitch\_S](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@Mitch\_S](https://forum.getodk.org/u/Mitch_S)\
**Post date:** [May 13, 2015, 4:45pm UTC](https://forum.getodk.org/t/creating-id-in-xlsform/4328/2 "2015-05-13T16:45:47Z")

</div>

I do not understand the question.

Look at the sample form and XLSForm documentation to get an understanding  
of the tools and how you use them.

> **[XLSForm](https://docs.getodk.org/xlsform/)**
>
> XLSForm is a standard for designing forms in Excel. XLSForms are simple to get started with and can represent complex forms. XLSForms can be created and edited by any application that works with.xl...

> **···**
>
> On Wed, May 13, 2015 at 7:42 AM, Mercy Adams wrote:
> 
> > how can I create an id for data or records in xlsform.
> > 
> > ## --
> > 
> > Post: [opendatakit@googlegroups.com](mailto:opendatakit@googlegroups.com)  
> > Unsubscribe: [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com)  
> > Options: [http://groups.google.com/group/opendatakit?hl=en](http://groups.google.com/group/opendatakit?hl=en)
> > 
> > * * *
> > 
> > You received this message because you are subscribed to the Google Groups  
> > "ODK Community" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Mitch Sundt  
> Software Engineer  
> University of Washington  
> [mitchellsundt@gmail.com](mailto:mitchellsundt@gmail.com)

---

<div class="post-metadata">

**Author:** ![Mercy\_Adams](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@Mercy\_Adams](https://forum.getodk.org/u/Mercy_Adams)\
**Post date:** [May 15, 2015, 2:56pm UTC](https://forum.getodk.org/t/creating-id-in-xlsform/4328/3 "2015-05-15T14:56:30Z")

</div>

for example: I want to create a xlsform containing student record and I  
want each student to have an id (identifier) that is unique and which will  
be created by me.  
how do I do this?

> **···**
>
> \> \>

---

<div class="post-metadata">

**Author:** ![jules\_rugwiro](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/jules_rugwiro/32/1738_2.png) [@jules\_rugwiro](https://forum.getodk.org/u/jules_rugwiro)\
**Post date:** [May 21, 2015, 11:33pm UTC](https://forum.getodk.org/t/creating-id-in-xlsform/4328/4 "2015-05-21T23:33:29Z")

</div>

Hello Mercy,

Did you think of using concat(val1,val2,...) to generate a concatenate of more than one variable as your student ID can be Faculty, Degree, DOB and so on to generate a Unique identifier or use the uuid() function to generate a random key for you (I won't recommend this as you won't have control on what is generated)

Cheers

Jules R.

> **···**
>
> On Wednesday, May 13, 2015 at 4:42:06 PM UTC+2, Mercy Adams wrote: \> how can I create an id for data or records in xlsform. \>

---

<div class="post-metadata">

**Author:** ![Mitch\_S](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@Mitch\_S](https://forum.getodk.org/u/Mitch_S)\
**Post date:** [May 15, 2015, 5:01pm UTC](https://forum.getodk.org/t/creating-id-in-xlsform/4328/5 "2015-05-15T17:01:48Z")

</div>

You will want to use a calculate expression to construct the student id  
from other input. The functions that you can use to construct that id are  
here: [https://opendatakit.org/help/form-design/binding/](https://opendatakit.org/help/form-design/binding/)

e.g., concat() will probably be useful.

See the sample XLSForm for how to define a calculated field.

> **···**
>
> On Fri, May 15, 2015 at 7:56 AM, Mercy Adams wrote:
> 
> > for example: I want to create a xlsform containing student record and I  
> > want each student to have an id (identifier) that is unique and which will  
> > be created by me.  
> > how do I do this?
> > 
> > > 
> > 
> > ## --
> > 
> > Post: [opendatakit@googlegroups.com](mailto:opendatakit@googlegroups.com)  
> > Unsubscribe: [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com)  
> > Options: [http://groups.google.com/group/opendatakit?hl=en](http://groups.google.com/group/opendatakit?hl=en)
> > 
> > * * *
> > 
> > You received this message because you are subscribed to the Google Groups  
> > "ODK Community" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Mitch Sundt  
> Software Engineer  
> University of Washington  
> [mitchellsundt@gmail.com](mailto:mitchellsundt@gmail.com)

---

<div class="post-metadata">

**Author:** ![Mercy\_Adams](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@Mercy\_Adams](https://forum.getodk.org/u/Mercy_Adams)\
**Post date:** [June 10, 2015, 12:18pm UTC](https://forum.getodk.org/t/creating-id-in-xlsform/4328/6 "2015-06-10T12:18:07Z")

</div>

do you have another approach to answer the question?

---

<div class="post-metadata">

**Author:** ![Mercy\_Adams](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@Mercy\_Adams](https://forum.getodk.org/u/Mercy_Adams)\
**Post date:** [May 19, 2015, 12:38pm UTC](https://forum.getodk.org/t/creating-id-in-xlsform/4328/7 "2015-05-19T12:38:35Z")

</div>

thanks, I will work on it ..

---

<div class="post-metadata">

**Author:** ![Mercy\_Adams](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@Mercy\_Adams](https://forum.getodk.org/u/Mercy_Adams)\
**Post date:** [June 10, 2015, 12:28pm UTC](https://forum.getodk.org/t/creating-id-in-xlsform/4328/8 "2015-06-10T12:28:16Z")

</div>

> I visited the link above and I try using the concat function but after
> 
> > uploading the xlsform, the id did not generate itself automatically.
> 
> can you show me how to use the concat function .  
> I used this and am not sure if it is correct. calcualate="concat(/data/staff\_serial\_num,'  
> with id: ', /data/age)"

> **···**
>
> \> \>\> \>

---

<div class="post-metadata">

**Author:** ![jules\_rugwiro](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/jules_rugwiro/32/1738_2.png) [@jules\_rugwiro](https://forum.getodk.org/u/jules_rugwiro)\
**Post date:** [June 15, 2015, 7:47am UTC](https://forum.getodk.org/t/creating-id-in-xlsform/4328/9 "2015-06-15T07:47:14Z")

</div>

Hello there,

The concat function can be used anywhere, constraint, relevant and  
calculation. based on your email it looks like you made a calculate type  
variable which is totally fine but remember calculate variable are ready  
only therefore has to be always used together with other variables like  
tex, integer and more to read their content.

Below is the very basic yet useful example of concat and lengt functions

```
type name label constraint calculation read_only required integer

```

ID\_V01 What is you random ID? .\>=1001 and .\<=1999 1 text ID\_V02 What are  
your names initials? string-length(.)\>=2 and string-length(.)\<=3 1  
calculate ID\_V03 concat('EID-',${ID\_V01},'-',${ID\_V02}) text  
ID\_V04 You  
have successfully generated the new employee ID as: ${ID\_V03}  
concat('EID-',${ID\_V01},'-',${ID\_V02}) 1 1  
hope you find it useful

Cheers

Jules R.

> **···**
>
> On Wed, Jun 10, 2015 at 2:28 PM, Mercy Adams wrote:
> 
> > I visited the link above and I try using the concat function but after
> > 
> > > > uploading the xlsform, the id did not generate itself automatically.
> > > 
> > > can you show me how to use the concat function .  
> > > I used this and am not sure if it is correct. calcualate="concat(/data/staff\_serial\_num,'  
> > > with id: ', /data/age)"
> > 
> > > > 
> > > 
> > > --  
> > > --  
> > > Post: [opendatakit@googlegroups.com](mailto:opendatakit@googlegroups.com)  
> > > Unsubscribe: [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com)  
> > > Options: [http://groups.google.com/group/opendatakit?hl=en](http://groups.google.com/group/opendatakit?hl=en)
> > 
> > * * *
> > 
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "ODK Community" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/opendatakit/a0P-KR-cOl4/unsubscribe](https://groups.google.com/d/topic/opendatakit/a0P-KR-cOl4/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to  
> > [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
