Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

How do I create / print a unique form ID?

Avatar

Level 3

I have created a simple work order. I have the need of assigning the work order an ID of some kind. I'm not really concerned about the ID topology. The ID should not be incremented for page copies. So let's say I had a hypothetical ID of 9000 and I printed 5 copies. All 5 copies should have the same ID of 9000. This ID should be present and ready to go upon the user opening the FORM. It should be calculated value with no interaction required (or able) from the users perspective, just open the work order and it's assigned this hypothetical ID and is ready to go.

I have looked around but can not fine a canonical answer on how this could be accomplished. Do any members of the community have and ideas?

1 Accepted Solution

Avatar

Correct answer by
Level 10

There is a FormCalc function for generating a unique identifier but it creates a pretty long and cumbersome string. The syntax is Uuid(0|1). Uuid(0) creates a string with no dashes and Uuid(1) adds dashes.

The following is a script I've used quite a bit, it creates a number based on the date and time. The result is a ten-digit number (number of seconds since the epoch).

You can take the null check out if you don't need it - it's there so that if the form is saved and re-opened the number stays the same. The script is on the Initialize event of a text field.

if (this.rawValue == null)

{

          var d = new Date();

          this.rawValue = Math.floor(d / 1000);

}

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

There is a FormCalc function for generating a unique identifier but it creates a pretty long and cumbersome string. The syntax is Uuid(0|1). Uuid(0) creates a string with no dashes and Uuid(1) adds dashes.

The following is a script I've used quite a bit, it creates a number based on the date and time. The result is a ten-digit number (number of seconds since the epoch).

You can take the null check out if you don't need it - it's there so that if the form is saved and re-opened the number stays the same. The script is on the Initialize event of a text field.

if (this.rawValue == null)

{

          var d = new Date();

          this.rawValue = Math.floor(d / 1000);

}

Avatar

Level 3

This should work just fine. Thanks!