Notification for user creation
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 12:13 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 12:27 AM
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 passwordModify 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.
