Skip to main content
Known Participant
January 24, 2019
Answered

unique identifier field with unique serial number

  • January 24, 2019
  • 1 reply
  • 2642 views

I am using the code below to get date and time stamp on my file  but I also want to add serial number with it which is unique to identify it later when I see list of that. Can anyone please help.

// get the current date and time
var d = new Date();
this.getField("UniqueNumber").value = util.printd("yymmdd-HHMMss", d);

This topic has been closed for replies.
Correct answer try67

So now what is happening is I have to  click on unique number textbox every time I do clear form, than only new number is generated. What I want is when I click on clear button unique number should be automatically displayed


Then you need to move the command to the custom calculation script of the field, and adjust it like this:

if (event.target.value=="") event.value = Math.random().toString().substring(2,7) + "_" + util.printd("yymmdd-HHMMss", new Date()); 

1 reply

try67
Community Expert
Community Expert
January 24, 2019

Is the serial number a fixed string? If not, how do you want to generate it?

PWS2020Author
Known Participant
January 24, 2019

Yes it should be a fixed string

try67
Community Expert
Community Expert
January 24, 2019

Then you can do it like this:

this.getField("UniqueNumber").value = "ABCD_" + util.printd("yymmdd-HHMMss", d);