Generate automated password whenever a new User is created manually in ServiceNow
Import
·
Oct 16, 2020
·
article
Hi All,
Recently, I have created a functionality where you can generate automated passwords and send notifications to the manually created new users in ServiceNow.
Please find below the Business Rule details:
Table: User(sys_user)
Before Insert
Conditions:
Created by is not System
(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);
}
//Generate Notification
gs.eventQueue("user.password", current, randomstring, current.email);
//Set values in User record
current.user_password.setDisplayValue(randomstring);
current.password_needs_reset = true;
current.update();
})(current, previous);
You can trigger the Notification and send the user's email and password in the parameters.
Note: You can even reuse the same code for reset the password.Thanks & Regards,
Sailesh J
Labels:
View original source
https://www.servicenow.com/community/itsm-articles/generate-automated-password-whenever-a-new-user-is-created/ta-p/2301070
