ECMAScript to generate a UUID

The code shown below was used in a recent project in order to generate a Unique Identifier when a User created a new Service Provider definition from within a User Application Workflow. When the Service Provider feed was consumed by the JMS Connector, the Connector checked the metadata present in the Identity Vault against the UUID sent as part of the XML file ‘header data’. If the two UUID values matched, the Service Provider long name was equal, and the Service Provider short name was equal, the XML file was accepted; otherwise the XML file was rejected.