Hi folks,
I found this explanation about generating an ID in an Infopath form. I am
not sure how to jscript it though. Does anyone have the code for this? If so
can you designate where my customized information needs to go in the code?
Thanks!
Matt...
Yes, you can use Date and Time, convert it to a string and strip the
unwanted characters.
The result can be something like this: 20040909122726 ( 2004/09/09
12:27:26 )
Set 1 text field to default value of Now() (use the expression button), and
set the format for the date and time.
Your ID# field would have an expression = concat(substring(field1, 1, 4),
substring(field1, 6, 2), substring(field1, 9, 2), substring(field1, 12, 2),
substring(field1, 15, 2), substring(field1, 18, 2))
However, if you have multiple users, this is not guaranteed to be random.
You would have to add something unique like an employees ID number or userID
(initials alone would not work).
Another approach is to have an external file that contains a number. As each
new document is opened, your code would open the file, increment the number
and save the file. That number used in the form would be sequential and
unique.
Greg Collins [InfoPath MVP] - 23 Mar 2005 21:37 GMT
If you are using managed code, you have direct access to generate GUIDs. If not, you can create a web service which does that for you. Or you can tie to a centralized database with a table that does nothing more than generate a new row on request and return that row number.

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
Hi folks,
I found this explanation about generating an ID in an Infopath form. I am
not sure how to jscript it though. Does anyone have the code for this? If so
can you designate where my customized information needs to go in the code?
Thanks!
Matt...
Yes, you can use Date and Time, convert it to a string and strip the
unwanted characters.
The result can be something like this: 20040909122726 ( 2004/09/09
12:27:26 )
Set 1 text field to default value of Now() (use the expression button), and
set the format for the date and time.
Your ID# field would have an expression = concat(substring(field1, 1, 4),
substring(field1, 6, 2), substring(field1, 9, 2), substring(field1, 12, 2),
substring(field1, 15, 2), substring(field1, 18, 2))
However, if you have multiple users, this is not guaranteed to be random.
You would have to add something unique like an employees ID number or userID
(initials alone would not work).
Another approach is to have an external file that contains a number. As each
new document is opened, your code would open the file, increment the number
and save the file. That number used in the form would be sequential and
unique.