Create and send password in Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2025 11:28 AM
Hi guys,
i have a flow, where user can order item, than it goes to approval, and if its approved, new user should be created and the credentials for log in should be send to the user. Everything in the flow works perfectly, the only issue is password. If i add in ,,create user record,, action the password field, and add script to the field to auto generate random number, the password is generated. But when I put it in the ,,send email,, action, so i can send i to the user together with the Sys Id and he can log in, the ,,password,, is in the email only as stars. I tried to add encrypting action, which i found, but it didn't work and the password was blank. Can please someone help me how can i solve it? I really spend so much time on it, but I am still not able to solve it. I can provide some detailed information or screenshots, but now I have no idea what to add to this post. Thank you very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2025 08:13 PM
Hi @tom1111 ,
Create a variable in the FD and assign the generated password to it and access this variable in the email notification.
If my solution works please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2025 08:23 PM
Hello @tom1111,
It is not recommended to share passwords via email as emails can be stored indefinitely, increasing the risk of exposure if compromised. Which means users with the access to the email logs would be able to see the generated password.
If the emails are added on your activity log on any of your ticket (Your RITM in this case) where the flow is being triggered from, any users with access to this ticket would be able to see the email which contains the password.
The method I am sharing would use event based notification to use parm2 for passing the password, which means the password would be also logged in the event logs.
However, if you are aware of all these risks. Please follow below steps:
- Create an event from your Event registry from
System Policy > Events > Registry (I am naming it event_name in this example) - If you don't have an Action within your flow where you are resetting the password. Please create one which has the RITM from your flow as an input and use the following script action:
var grUsr = new GlideRecord('sys_user');
grUsr.addQuery('user_name', "abel.tuter"); //Adjust as per your query
grUsr.query();
var newpw = "";
if (grUsr.next()) {
var availablechars = "1234567890ABCDEFGHIJKLNOMPQRSTUVWXYZabcdefghijklnmopqrstuvwxyz";
for (var i = 0; i < 16; i++) {
randomNumber = Math.floor(Math.random() * availablechars.length);
newpw += availablechars[randomNumber];
}
//Trigger the event which would send the notification to the user
//Replace "glide_record_object" with the record where the flow is being triggered from (Your RITM input)
//Replace "recipient" with the user sys_id/email
gs.eventQueue('event_name', 'glide_record_object', recipient, newpw);
grUsr.user_password.setDisplayValue(newpw);
grUsr.password_needs_reset = true;
grUsr.update();
}
- Adjust the trigger on the notification so that the trigger is based on your event and select the event you created
- Recipient should be Event parameter 1 ("Who will receive" section)
- Within your notification content, you can access the password as:
${event.parm2}
- User now can use the password to login in "your_instance.service-now.com/login.do" and will get prompted to reset the password after first login.
I hope it helps!
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 07:57 AM
Hello @tom1111 ,
I hope you are doing well! Was my answer helpful? If so, kindly accept the solution and close the thread so that it benefits future readers.
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 09:34 AM
let the outbound email have the passwords, you can't encrypt those, but you can have restriction on sys_email table with ACL.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader