Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / March 2005

Tip: Looking for answers? Try searching our database.

generating an ID

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt - 15 Mar 2005 18:27 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.