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

Avatar

Niall_O_Donovan

Avatar

Niall_O_Donovan

Niall_O_Donovan

03-02-2009

Hi Jono,



The issue may be that "LiveCycle Designer ES defines day one for the epoch for all date functions as Jan 1, 1900".



The website you referred to has the following statement "Epoch has a few meanings (see also http://dictionary.reference.com/search?q=epoch). The definition that we'll use is "0" in computer time. While there are folks who will argue this, for our purposes, this "0" time on our calendar was January 1, 1970 00:00:00 GMT"



That would explain why the answer is approximately 70 years off!!



I think I will use your script (thanks!), but truncate the answer to the last 8 digits.



Good luck,



Niall

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

03-02-2009

Doh! Haha - good catch!

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

03-02-2009

And here it is in javascript should anyone want it. This gives a 10 digit number.



var d = new Date();

//divide result by 1000 to get seconds and round off

this.rawValue = parseInt(d / 1000);



This has been a good excercise. I'm just getting into the scripting after not having done anything coding-like for about 20 years.

Avatar

Avatar

Niall_O_Donovan

Avatar

Niall_O_Donovan

Niall_O_Donovan

03-02-2009

Thanks Jono,



I had not come across parseInt before. One for the books 😉



N.

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

03-02-2009

Theodoros:



I'm trying to figure out how to stop the field from changing too.



I found the following formcalc code on the AUC forums http://www.acrobatusers.com/forums/aucbb/viewtopic.php?pid=43197



if ($.rawValue==null)then

$.rawValue = time()

else $.rawValue

endif



and modified it for my javascript:



if (this.rawValue == null) {

var d = new Date();

//divide result by 1000 to get seconds and round off

this.rawValue = parseInt(d / 1000);

}

else {

this.rawValue = rawValue;

}



I tried saving the form with the generated number and it didn't regenerate on opening. It probably needs to be more robust than this for general use but it works enough for my testing purposes.