- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2020 09:14 PM
Hi All,
We have a requirement where when a new user is created manually in ServiceNow, a email needs to be triggered with the password(Which ServiceNow automatically sets) along with the link to change the password. Also I want ServiceNow to set passwords automatically to the newly created users.
Is there any way we can get this done?
Regards,
Sailesh J
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 10:25 PM
Hi Mohit,
Thank you for your time.
I have completed the requirement. I have written a after - Insert Business Rule for getting this functionality.
(function executeRule(current, previous /*null when async*/ ) {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var string_length = 8;
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum, rnum + 1);
//gs.eventQueue()
}
gs.eventQueue("user.password", current, randomstring, current.email);
current.user_password.setDisplayValue(randomstring);
current.password_needs_reset = true;
// gs.log("randomstring: " + randomstring, 'c1006');
// gs.log("password: " + current.user_password, 'c1006');
current.update();
})(current, previous);
Hope this helps for anyone 🙂
Regards,
Sailesh J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2020 11:49 PM
Thank you Mohit.
Our client needs the password to be autopopulated and user needs to login to that password which got generated. Please provide the code once done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2020 08:46 PM
Hi Mohit,
Have you got the fix by any chance?
Regards,
Sailesh J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2020 11:39 PM
Hi Sailesh,
I tried for it but everything is reaching to dead end, i am afraid you need to remove the password value from email script and mention the line to reset the password.
Instead of making the user change its password again after first login, you can uncheck the "Password reset" checkbox and make your notification run on some custom field value change, in that way they have to change the pwd once.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 10:25 PM
Hi Mohit,
Thank you for your time.
I have completed the requirement. I have written a after - Insert Business Rule for getting this functionality.
(function executeRule(current, previous /*null when async*/ ) {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var string_length = 8;
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum, rnum + 1);
//gs.eventQueue()
}
gs.eventQueue("user.password", current, randomstring, current.email);
current.user_password.setDisplayValue(randomstring);
current.password_needs_reset = true;
// gs.log("randomstring: " + randomstring, 'c1006');
// gs.log("password: " + current.user_password, 'c1006');
current.update();
})(current, previous);
Hope this helps for anyone 🙂
Regards,
Sailesh J