I had a could things I needed for a project that weren't standard in the functions list. I googled around and snagged some java script code that works just fine and made a custom function that I reuse across many of my projects. Here is a quick tutorial and example of code.
-Asa
1. Create a new custom function.
2. Give the custom function a name. There is no input parameter required
3. Enter the code as shown below, which will return a valid guid to any string variable.
Code:
var s = [], itoh = '0123456789ABCDEF';
for (var i = 0; i <36; i++) s[i] = Math.floor(Math.random()*0x10);
s[14] = 4;
s[19] = (s[19] & 0x3) | 0x8;
for (var i = 0; i <36; i++) s[i] = itoh[s[i]];
s[8] = s[13] = s[18] = s[23] = '-';
return s.join('');
-Asa
1. Create a new custom function.
2. Give the custom function a name. There is no input parameter required
3. Enter the code as shown below, which will return a valid guid to any string variable.
Code:
var s = [], itoh = '0123456789ABCDEF';
for (var i = 0; i <36; i++) s[i] = Math.floor(Math.random()*0x10);
s[14] = 4;
s[19] = (s[19] & 0x3) | 0x8;
for (var i = 0; i <36; i++) s[i] = itoh[s[i]];
s[8] = s[13] = s[18] = s[23] = '-';
return s.join('');
Leave a comment