uniqueid(
FIELD
,
ROOT
)

The uniqueid( function generates ID codes with a text root and a numeric suffix (for example Jeff261).


Parameters

This function has two parameters:

field – is the name of the field that will contain the ID code. The function needs to know the name of this field so that it can scan the field to find an ID code that has not been used yet. The field name should be surrounded by quotes. For example, if the name of the field is ID, you should use "ID" as the parameter.

root – is the text root that the ID code will be based on. This root may contain any kind of character, but it should not end with a numeric digit. To get a root that will be unique for each different computer you have, use the info(“user”) function for the root.


Description

Although you may find other uses for it, the uniqueid( function was designed specifically for creating unique Smart Merge serial numbers. Whenever a new record is added to a database that supports Smart Merge you must make sure that the ID and Modified fields are filled in. The best way to do this is to add a .NewRecord automatic procedure to your database. The two lines shown below will fill in the proper values. (Note: The code in this example is not a complete .NewRecord procedure, see Implicitly Triggered Procedures for full details on how this procedure works.)

Modified=superdate( today(),now())
ID=uniqueid("ID",info("user"))

The uniqueid( function will scan the ID field to find the next serial number available. For example, if you are using a computer with a user name of Sam and the highest Sam serial number is 296, the uniqueid( function will return the value Sam297. Creating a .NewRecord procedure may not be enough to insure that the ID and Modified fields are always filled in. If your database has procedures that create new records, the .NewRecord procedure will not automatically be called. You must modify these procedures to call the .NewRecord procedure (using the Call statement). Another possible problem area is imported data. When you import data into the database you must make sure that the ID and Modified fields are filled in. The procedure listed below will do the job. You should also run this procedure when you first add Smart Merge to your database, so that all your existing data will be properly identified.

select ID=""
field Modified
formulafill superdate( today(),now() )
field ID
formulafill uniqueid("ID",info("user"))
selectall

See Also


History

VersionStatusNotes
10.0No ChangeCarried over from Panorama 6.0.