GUID data typeOfficial Content

GUID use is important when working in distributed environments.

Genexus Internal use

 GeneXus uses this data type internally to uniquely identify each type of object.

What for? The idea is that if an object is exported to another KB and modified there when it is later imported back to the source KB, the object will be identified as corresponding to the originally-exported object. Also, if an object is imported into a KB where an object with the same name but different GUID already exists, GeneXus will know that even though they both have the same name, the imported object does not correspond to the existing object.

Generated applications use

In generated applications, there is a very similar need for using it. Let’s imagine, for example, a POS (Point Of Sale) type application that works disconnected from the head office, where data is unloaded every night.

The most common way now to copy the data without having to modify the values of all the keys is to have a combined key that includes the number of the point of sale or branch terminal.

Imagine the second or third level of this transaction. It will have a key consisting of an attribute whose sole purpose is to help make its key unique. Each time it is referenced in another transaction, both attributes will have to exist, generating unnecessary index maintenance.

Using the GUID data type, you can ensure a unique key and avoid this type of problems.

Its use does not have to be limited to registries in our tables, it can also be used to help file generation (avoiding the duplication of same-name files), Site Key generation, and any other cases where obtaining a globally unique identifier is required.

How is it used in GeneXus?

Static Methods

  • GUID.NewGuid()
  • GUID.Empty()  


If &GUID <> GUID.FromString("2ac61739-b024-438e-a6e5-e507d8be4667")
     msg("Bad Site Key")

Functions/ Instance methods

  • ToString() return a string with XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX format.
  • FromString() return GUID created by a hexadecimal string , with or without the "-" delimiters.
  • IsEmpy()
  • IsNull()
  • SetEmpty()
  • SetNull()


msg("GUID: " + &GUID.ToString())

GUID attributes also have an “auto generate” property, where default = TRUE if they are key and = FALSE if not. It indicates that a new GUID value is generated when an insertion is made.

In the following example, the Customer and Invoice entities have a universal identifier; this will enable several unconnected branches to generate new values for the entities and to easily update each other, as well as the head office.

GUID Data Type Example 1


Events Web Panels events, Server-side Events in Smart Devices, Client-side Events in Smart Devices
Languages .NET, Java,
Interfaces Web, Smart Devices
SD Generators iOSAndroid

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.