There may be times when you will need to generate a unique number or code as part of a form screen's data output. This is common for order numbers, invoice codes, document IDs, etc. You can do this by using a formula to create a text value that you will assign to the dynamic value property of the designated form field. Essentially, you'll link various bits of data to create a meaningful and reasonable unique code. We say 'reasonably unique' because ultimately the formula will generate a unique code for the local device context.

It's important to use data elements like date/time or user's details to ensure that the resulting code cannot be duplicated on other users or devices. We are often asked if it is possible to have a central sequential number that all devices are aware of. This way the codes on all form entries could be sequential and numbered in order of entry/capture. We support this primarily through data template by making  a special built-in placeholder called ##{{%ENTRYID}} available.

This placeholder is not available for form use. It's only available in data templates so that you can produce numbered outputs. For further help refer to the 'Built-in Placeholder' article under the data templates section of our documentation.

Other than the ENTRYID option on data templates, we don't support form-side central numbering as there is no guarantee about network connectivity at the time of capturing the form. As such we recommend generating codes in a device specific manner.

We recommend you use something like the counter() function linked with the userexternalid()/useremail() and the format-date() on today()/now().

The external ID on users is particularly useful for storing something like a payroll ID or other code that has meaning in the ultimate destination system. If you must have a central sequential number, you will need to handle this on your backend external system, e.g. when form entry data is moved into your relevant backend system. At that point assign each entry a new centralized sequential number.

Here are some examples of formula to generate device-specific unique codes:

uuid(10) gives: X7E5F3A2L3

random() gives: 0.14935942 which you can then multiply, round, etc. to get the desired precision.

counter() gives you a sequentially increasing number that is device-specific.

We strongly recommend joining the device counter() value with date and/or user identifiers, such as these below:

concat(format-date(now(), 'yyyyMMdd'), '-', counter()) gives you: 20140313-39

concat(format-date(now(), 'yyyyMMdd'), '-', userexternalid(), '-', counter()) gives you:  20140313-USER1-39

Did this answer your question?