Generate a Random Universally Unique Identifier

Steps

  1. Create a project utils_uuid.
  2. Create a JavaScript service with the name uuid_random_generator.js.
  3. Enter the following content:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var uuid = require('utils/modules').getUuid();
var response = require('http/v3/response');

var generated = uuid.random();

console.log(generated);
uuid.validate(generated);

console.log('Randomly Generated UUID: ' + generated);
response.println(JSON.stringify('Randomly Generated UUID: ' + generated));

response.flush();
response.close();


For more information, see the API documentation.

Edit