Notification for user creation
- 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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 02:52 AM
iam getting the below log rest all logs looks good
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 02:59 AM
Hi @jobin1,
Email Configuration Issues:
- Verify your ServiceNow instance's email configurations under System Properties > Outbound Mail. Ensure that SMTP settings are correctly configured and that there are no connectivity issues with your mail server.
Email Format and Recipient Address:
- Double-check that current.email contains a valid email address in the correct format (e.g., user@example.com). If current.email is blank or malformed, the email sending will fail.
ServiceNow Email Logs:
- Check the ServiceNow email logs (System Logs > Email Logs) for more detailed error messages or warnings related to the failed email attempts. This can provide insights into specific issues such as delivery failures or rejected emails.
- Also check below script :
(function executeRule(current, previous /*null when async*/) {
// Log to track the flow
gs.log('Executing Business Rule for new user creation. User Name: ' + current.user_name + ', Email: ' + current.email);
if (current.email) {
// Trigger the custom event
gs.eventQueue('user.creation.notification', current, current.user_name, '');
// Send notification
var email = new GlideEmailOutbound();
email.setSubject('Your ServiceNow Account Details');
email.setBodyFromNotification('ec3bac3983578a10b7594d226daad371'); // Replace with your actual notification sys_id
email.addRecipient(current.email);
var sent = email.send();
if (sent === true || sent === 'true') {
gs.log('Notification email sent successfully to ' + current.email);
} else {
gs.log('Failed to send notification email to ' + current.email + '. Error: ' + sent);
}
} else {
gs.log('No valid email address found for user ' + current.user_name);
}
})(current, previous);
Thank you, please make helpful if you accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 03:01 AM
I am getting the below log rest the logs looks good and i tried giving my ID static in whom to receive then I got the mail attaching a screenshot
now i think recipient-related information is not getting in the notification from BR i guess
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 12:21 AM
my case is on user creation and how to get the real-time password as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 12:36 AM
That all depends on how the password is set. With SSO they already know their password. If you are setting a default password on every user creation, you can just add that as text.
If you are just letting ServiceNow set the passwords, it would be best to have the 'reset password' functionality activated and let users login on that page, so they can create their own.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
