Creating a Microsoft/DCE compliant GUID in Coldfusion/Railo

Coldfusion and Railo come with a CreateUUID() function that creates a 35-character string representation of a unique 128-bit
integer in a 8-4-4-16 format: xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx. This format doesn’t comply with the Microsoft/DCE standard for GUIDs that require a 8-4-4-4-12 format such as xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. You usually find about this incompatibility when trying to interact with some dotNet webservice.

The easiest solution to this problem is to fallback to Java:

   var uuidLibObj = createobject("java", "java.util.UUID");
   var guidStr = uuidLibObj.randomUUID().toString();

The resulting variable guidStr will contain a correctly formatted GUID.