KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Generating UUID's in Converted Databases
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: June 29, 2010

The new 4D v12 command Generate UUID can be used to automatically create unique identifiers in v12 databases. It can be used with the new field setting "UUID Format" for Alpha fields. One of the challenges of this feature is that developers are likely to want to implement it in existing databases that do not have UUID's. A great way to do this is to use the APPLY TO SELECTION command.

For example, on one of your existing tables you can add a new field and assign it the UUID format as shown below:



Then you can run the following code to assign a UUID to all existing records in the database. Once this has been done turn on the Auto UUID feature and you will have automatic UUID's for all future records.

ALL RECORDS([Table_1])
APPLY TO SELECTION([Table_1];[Table_1]Field_1:=Generate UUID)