@ed_truqc I was just looking at some code this morning that I worked on awhile ago and found a function I had that did this and is a bit more simple and hopefully less prone to errors.
//Generate UUID
function generateUUID() {
var d = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = (d + Math.random()*16)%16 | 0;
d = Math.floor(d/16);
return (c=='x' ? r : (r&0x3|0x8)).toString(16);
});
return uuid;
}
// Random number gen based on the time stamp
pm.environment.set("uuid", generateUUID());
console.log(pm.environment.get("uuid"));