Automatically Create Users in 'sys_user' table from a table contain information/data about user (BR)

Ashish Moghe
Tera Contributor
current - The table where your user data is present.
----------------------------------------------------------------------------------------------------------------------------
var gr = new GlideRecord("sys_user");
 
/*
    * For users variable.
    * There are two field in the form 
    * 1. contains single field.
         * eg. FirstName LastName
    * 2. field for email Id
*/
var users = [current.getValue('u_name')];

var newuser = [],
    userslen = users.length,
    b = 0;
for (var i = 0; i < users.length; i++) {
    var k = users[i].split(" ");
    newuser.push(k);
}
for (b; b < newuser.length; b++) {

    var first = newuser[b][0];
    var last = newuser[b][1];
    var id = current.getValue('u_candidate_emailid');
    var userId = newuser[b][0].toLocaleLowerCase() + "." + newuser[b][1].toLocaleLowerCase();


    gr.newRecord();

    gr.setValue('user_name', userId);
    gr.setValue('first_name', first);
    gr.setValue('last_name', last);
    gr.setValue('email', id);

    gr.insert();

}
 
 
Please mark helpful or correct, if my answer is applicable for your case.
Thanks & Regards,
Ashish Moghe
0 REPLIES 0