- 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-13-2020 01:32 AM
No it does not create the email address for the user, its just add the email of that user to cc, but you can ignore that line. That is not required as you are directly setting the recipient email for notification.
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020 12:48 AM
Hi Mohit,
Forgot to mention.
ServiceNow is not allowing the newly created user to login using the default password which we used in email script. Do you know why this is happening?
Regards,
Sailesh J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020 01:32 AM
Let me look into this,
Can you please share the screenshot, which is not allowing the user to login.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020 06:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2020 10:12 PM
HI Sailesh,
Sorry for the trouble with the code, but i was checking that the password which comes through glide property that is some default password which needs to be reset on first login.
For resetting the pwd the user needs to click on forgot password button.
here is the link which you can provide to the user for logging in.
Now i will suggest you instead of passing the pwd in mail you can just mention their mail id and write a line that they need to click on the forgot pwd button to reset and they can follow the above link also to follow the steps.
Now after this one more challenge will come that when you will reset the pwd and log into snow instance after this it will again ask you to change the pwd as we have checked the password reset checkbox.
Note: Instead of all this we can write one script to auto populate the pwd and i am working on that once that is done i will share the solution with you.
Then you will not require the email script, it will be done with the help of client script only, i think.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)