- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 10:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2016 01:55 AM
Hi munimohan,
var usr = new GlideRecord('sys_user');
usr.initialize();
usr.first_name= 'Prashant';
usr.last_name = 'Kumar';
user.insert();
Mark answer as correct if it satisfies.....
Cheers,
Prashant
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2016 02:01 AM
Why do you want to create a single user using Background Script? You can create a user directly by going to User Administration >> Users >> New
If you plan on creating multiple users, then you should import them from an spreadsheet by creating a datasource.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2016 02:37 AM
thanks to all
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 01:36 PM
Hi munimohan ,
To create a single user I will recommend you directly utilize Users module to create new i.e. by going to User Administration >> Users >> New
but in case you need to create multiple users at a single time you can utilize the below code :
var user = new GlideRecord('sys_user');
var n = 10;
for(var i =0; i<n;i++)
{
user.initialize(); // for initializing user every time the loop runs
user.user_name = "TESTING"+i;
user.first_name = "TEST";
user.last_name = "ING"+i;
user.mobile_phone = "986745321"+i;
user.insert(); // for inserting the data every time the loop runs
}
NOTE : I have used variable n as the number of users you want to create and provided with 4 random field values to populate for each user . You can play with the fields as per your requirement and check on results.
Thank you