Generating a Unique Number/Code

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 support this scenario primarily on the Output Template side by making available available a special built-in placeholder called {{%ENTRYID}}. This special placeholder is not currently available for form use - it is only available on Data Templates. So you can produce numbered outputs if you use data templates. For more information, please refer to the "Built-in Data" article under the Output Templates section of our Knowledge Base.

We recommend you use something like the counter() function concatenated with the userexternalid()/useremail() and say 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

    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 something like: 20140313-39

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


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.