I have a form that I need to have a unique ID generated when the form is first opened, and stays the same once saved. I thought using the date/time would work, e.g.; 01012015012556 created from the date/time of 01/01/2015 01:25:56, but can't figure out how to get it to display properly. It can't be a random number just in case it happens to generate the same number. Any ideas? I'm using LiveCycle Designer ES2
Solved! Go to Solution.
using the date function is your best shot, especially if it's when the form is open at first.
you have the choice of using each functions of a date to create your own UID or use the getTime() function
Hope this help!
another way would be the UUID() Method in FormCalc that will — as stated in the FormCalc reference — return a
$ = Uuid(1)
fills a text field with something like 0e611f47-0eac-41a7-aee5-578c43a61798
I do have one question, if the form is submitted via a submit button, will the UUID stay the same when received? It would need to stay the same no matter if it is submitted or saved.
My curiosity was too high to not test the Uuid function of Formcalc as its result doesn't look like a unique id to be generated and considered unique!!
I've made a small test with 1000 samples of this function to see if there could be a leak with duplicates.. There was no duplicate in that case..
But to make sure I've made a test with 100,000 samples and actually found duplicates more than once, as you said at least extremely like a unique id but it still can create duplicates unfortunately
I've also noticed that it is not rotating through time, which would create a unique id depending on the milliseconds in a second or minutes/hours, it can create duplicates whenever but in a small margin of error as I had 8 duplicates in 100,000 samples and the duplicates were starting to be generated more and more frequently...
I don't think a form would be used over 10,000 times to have that many unique ids, but I don't think using this method is good idea, because it could generate a duplicate at any time...
with the code given by radzmar it should never change the uid given when submitted or saved, the if statement is making sure that it holds a unique id before it assigns one to the form.
Also, you would have to make sure that your reset data button, if you have one of course, does not reset your uid... otherwise it will create another uid once it is null..