Adding Control Number to Form

Avatar

29-12-2008

I am new to LiveCycle Designer. Is there anyway to add a control number to forms? I would like to have it so that when the form is submitted, the form number will increase by one. Any suggestions?

Replies

Avatar

27-01-2009

Paul, how can I include milliseconds into my script above?

Can you help me with this addition please?

Thanks

Avatar

Avatar

pguerett

Avatar

pguerett

pguerett

27-01-2009

It does it by default. simply use the FormCalc command like this:



FieldName.rawValue = time()

Avatar

30-01-2009

Paul, there is any way to freeze the field text with the unique number, so any time we reopen the form, the number will remain the same?



Thanks

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

02-02-2009

You can also use a UUID (Universally Unique Identifier)



Formcalc:

$.rawValue = Uuid(1)



Which results in a string like this:

340e4465-559a-4fbd-bac2-455a7ac85248



I've just been playing around with this function recently but the resulting string is rather unwieldy. I like the idea of using Time(), it gives an easier-to-deal-with number as a result - thanks Paul!

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

02-02-2009

[subscribing to thread]

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

02-02-2009

Actually, I noticed that Time() really only returns the number of milliseconds in the current day so I tried:

$ = Date() * 86400 + Time()

To get the actual milliseconds since epoch (86400 milliseconds in a day).



But that didn't work out quite right (math isn't my best attribute ;).



Any ideas?

Avatar

Avatar

Niall_O_Donovan

Avatar

Niall_O_Donovan

Niall_O_Donovan

02-02-2009

Hi Jono,



86400000 (8.64e+007) milliseconds in a 24 hour period. Using your script you end up with a 13 digit reference.



Niall

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

02-02-2009

Thanks Niall, forgot those pesky zeroes...



Still not working correctly though - how would I combine time() and date() to get the proper number of milliseconds? Even with the correct number of zeroes it isn't working correctly.

Avatar

Avatar

Niall_O_Donovan

Avatar

Niall_O_Donovan

Niall_O_Donovan

02-02-2009

hmmm,



Seems to work here...



$ = Date() * 84600000 + Time()



I tried it longhand as well and got the same answer... The next problem is getting it to stay static on reopening. I am thinking of getting a convert to string script on the submit button and generating a barcode...



Enough for now 😉



Good luck,



Niall

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

03-02-2009

The number that comes out isn't correct, it's 13 digits and if I put it into a time converter it comes out as: Tue Oct 27 2076 08:45:05 (should be today's date, and time is wrong).



http://www.esqsoft.com/javascript_examples/date-to-epoch.htm



Ah well, not really important except to figure out what I'm doing wrong math-wise. Maybe I'll try mucking with javascript.



Or maybe just the time in milliseconds for the day is enough, but I thought getting the full amount of milliseconds since epoch would be better - that way there's almost zero chance of a collision.