Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to create User id ,on submission of first name and last name ?

Rajababu
Giga Guru

Hi ,

I want to create ,User id on combination of First name and last name .

When user submit if user id already exists in sys_user table ,it will create other than that .

9 REPLIES 9

Mittu ,

How I can create unique user id ?

Nikhil Phalke
Kilo Guru

Hi,

 

Please go through the attachment.

 

Regards

Nikhil

Nikhil, There is issue if user id already exists then how it will create other user id .

Above will simple way there will be limitation correct then how I can create 5000 user id arleady exists .

How I can make unique id creation ?

Hi,

 

For that you can use the asynch business rule.

Below is the code which work properly as per your requirement.

( I have tested the code in background script)

var gr = new GlideRecord('sys_user');
gr.setLimit(100);  // set limit for the number of records


gr.addQuery('active', 'true'); // add condition as per your requirement
gr.query();
while(gr.next())
{
gr.user_name=gr.getValue('first_name')+'.'+gr.getValue('last_name');
gr.setWorkflow(false);
gr.update();
}

 

Please mark my answer Helpful and Correct based on the impact.

Regards

Nikhil

Thanks all your effort .

Might be didnt explained in correctly .

 5000 emails - like user id created into sys user with same user id

 

like rajy - First name - Rajive Last name Yumbo

rajy - Frist Name - Rajive Last Name Yumenda

........etc.

Now ,How I can create unique one .

becuase if user alreday exists then it will not create ,how i can create new one ?