Often you will need to generate unique number or code as part of a particular Form screen’s data output.

This is common in cases like order numbers, invoice codes, document ids and many other scenarios.

You can achieve this by using a formula to create a text value that you assign to the Dynamic Value property of the designated Form field.

Essentially you’ll concatenate various bits of data together to create a meaningful, but reasonably unique code.

Note we say “reasonably unique”.

This is because ultimately the formula will generate a unique code for the local device context.

It is important to use data elements like the date/time or the user’s details to ensure that the resulting code cannot be duplicated on other users or devices.

Often we are 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 cannot support this scenario primarily because there is no guarantee about network connectivity at the time of capturing the form.  So what happens if the user is disconnected at the time of capturing a form?

Also bear in mind that there can be a time lag between form entry capture on the device and when the data actually gets uploaded to the server (again depends on network connection and other device factors).

As such you should stick to generating codes in a device specific manner.

If you must have a central sequential number, then you need to handle this on your backend system.

i.e. when form entry data is moved into your relevant backend system, at that point assign each entry a new centralised sequential number.

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

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.

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

uuid(10)
gives something like: X7E5F3A2L3

random()
gives something like: 0.14935942 which you can then multiply/round etc to get the desired precision.  It’s not guaranteed to be unique but may work for you in some circumstances.

counter()
gives you a sequentially increasing number that is unique on this mobile device.  But two or more of your devices might come up with the same number.

concat(format-date(now(), ‘yyyyMMdd’), ‘-‘, counter())
gives something like: 20140313-39

concat(format-date(now(), ‘yyyyMMdd’), ‘-‘, userexternalid(), ‘-‘, counter())
gives something like: 20140313-USER1-39

How to Login to the Platform. Generate a Unique ID Code. Send Form Data to a Web Service. number(). Create a New Doc. format-num(). int(). Contextual Functions. Add a User or Device. cosh(). Email Form Results. Excel Financial Functions. userfirstname(). Date/Time Functions. userexternalid(). today(). Manage Docs. Location Functions. Process Steps. imgurl().