Hi Mike,
I have used the following technique to auto-number a form:
1) Create a hidden field and use a FormCalc function to get the date-time when the form is opened
// form1.purchaseOrder.header.DateTimeField1::initialize - (FormCalc, client)
// The hidden field DateTimeField1 is used as the source for the P.O. number.
// The function, below, returns a string in the format 20081107055344 where 20081107 is YYYYMMDD and 055344 is HHMMSS.
$.rawValue = Concat(Num2Date(Date(), "YYYYMMDD"), Num2Time(Time(), "HHMMSS"));
2) On the target id field extract the month, day, and time (down to the millisecond)
// form1.purchaseOrder.header.poNum::calculate - (JavaScript, client)
// DateTimeField1 is used to generate a unique P.O. number (see the initialize event on DateTimeField1).
// DateTimeField1 produces a value in the format 20081107055344, for example. In this example the substring
// removes the year 2008 to produce the P.O. number 1107055344.
var str = form1.purchaseOrder.header.DateTimeField1.rawValue;
this.rawValue = str.substring(4,18);
There are many techniques including the creation of a random number using the JavaScript math.random() method.
See https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Math/random
Steve