there is a scenario where we need to generate a unique id for the records inserted in a table through importing?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 03:44 AM
there is a scenario where we need to generate a unique id for the records entered in a table through importing? is that possible while importing or after Import how it can be done?
Appreciate you help!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 04:09 AM
I developed this script a while back. If you cant use sys_id, below script might help.
Below will generate 100 random unique strings, a mix of special chars, lower case, upper case and numbers.
===================
for( var i=0; i<100;i++){
String.prototype.pick = function(min, max) {
var n, chars = '';
if (typeof max === 'undefined') {
n = min;
} else {
n = min + Math.floor(Math.random() * (max - min + 1));
}
for (var i = 0; i < n; i++) {
chars += this.charAt(Math.floor(Math.random() * this.length));
}
return chars;
};
String.prototype.shuffle = function() {
var array = this.split('');
var tmp, current, top = array.length;
if (top) while (--top) {
current = Math.floor(Math.random() * (top + 1));
tmp = array[current];
array[current] = array[top];
array[top] = tmp;
}
return array.join('');
};
var specials = '!@#$%^&*()_+{}:"<>?\|[];\',./`~';;
var lowercase = 'abcdefghijklmnopqrstuvwxyz';
var uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var numbers = '0123456789';
var all = specials + lowercase + uppercase + numbers;
var password;
password += specials.pick(3,5);
password += lowercase.pick(3,5);
password += uppercase.pick(3,5);
password += numbers.pick(3,5);
password += all.pick(3, 7);
password = password.shuffle();
gs.print(password);
password ="";
}
===================
You can run this loop as per the number of records in the update set, and append this string to auto-generated number on the form to get a unique id.
There can be many possible ways to leverage this script.
Mark your feedback( Like or Helpful or Correct) as per the impact of my response. Cheers!
Vab