Notification for user creation

jobin1
Tera Expert

in ServiceNow whenever a user profile is created we have to send a notification to that user and it includes the user id, password (which is set at the time of creation), and the ServiceNow URL ->https:/.service-now.com
how we can achieve this?

10 REPLIES 10

Yashsvi
Kilo Sage

Hi @jobin1,

Generate the Password:

Use a Business Rule or a Script Include to generate a random or system-generated password at the time of user creation. Ensure this password meets your organization's security policies

var newPassword = gs.generateGUID(); // Generate a random password

Modify the Business Rule:

var user = new GlideRecord('sys_user');
user.addQuery('sys_id', current.sys_id); // current.sys_id represents the newly created user's record
user.query();
if (user.next()) {
    // Generate and set the password
    var newPassword = gs.generateGUID(); // Generate a random password
    user.password.setDisplayValue(newPassword); // Set the password (assuming it's stored in the sys_user table)
    user.update();

    // Send notification
    var email = new GlideEmailOutbound();
    email.setSubject('Your ServiceNow Account Details');
    email.setBodyFromNotification('notification_sys_id'); // Use the sys_id of your email notification
    email.addRecipient(user.email);
    email.send();
}

Thank you, please make helpful if you accept the solution.