User Notification

manju12
Tera Expert

Hi Team, 

 

I need to send notification to user, when user changes the password on below form.

 

I have tried using business rule, event registry and notification but it is not working. Could you please help me out.

 

Thanks,

Manju

image (1).png

8 REPLIES 8

Itallo Brandão
Mega Guru

Hi Manju,

The reason your Business Rule is likely failing is that the Password field on the sys_user table is special (one-way encrypted). For security reasons, the condition current.password.changes() does not always evaluate to true in Business Rules depending on how the update was made (e.g., via specific APIs).

Since this form looks like a Service Portal Widget (or a UI Page), the best and most reliable approach is to trigger the event directly from the Widget's Server Script where the logic actually runs.

Here is the step-by-step solution:

Step 1: Register the Event

  1. Navigate to System Policy > Events > Registry.

  2. Click New.

    • Event name: user.password.changed.custom

    • Table: sys_user

    • Fired by: Change Password Widget

  3. Save.

Step 2: Update the Widget Server Script

You need to find the code that handles the "Submit" action on that form.

  1. Ctrl+Right Click on the form/widget and select Instance Options (or open the widget in Service Portal > Widgets).

  2. Open the Server Script tab.

  3. Look for the section where the password update happens (it might look like user.update() or a call to a Script Include).

  4. Add the event trigger inside the success condition:

JavaScript
 
// Example of where to place the code in your widget script
if (passwordChangedSuccess) { // This variable depends on your existing script logic
    
    // --- ADD THIS LINE ---
    // gs.eventQueue('event_name', record, parm1, parm2);
    gs.eventQueue('user.password.changed.custom', gs.getUser(), gs.getUserName(), '');
    // ---------------------

    data.msg = "Password changed successfully";
}

Note: Ensure you pass the User ID or User Object as the second parameter so the notification knows "Who" the recipient is.

Step 3: Configure the Notification

  1. Go to your Notification.

  2. Send when: Event is fired.

  3. Event name: user.password.changed.custom

  4. Who will receive: Event parm 1 (or select "User/Recipient" depending on how you passed the data).

This bypasses the limitations of the Business Rule and ensures the email only goes out when the "Submit" action on that specific form is successful.

Hope this helps you get the email triggering!

If this response helps you solve the issue, please mark it as Accepted Solution.
This helps the community grow and assists others in finding valid answers faster.

 

Best regards,

Brandão.

Chaitanya ILCR
Mega Patron

HI @manju12 ,

you can create  the notification like this

ChaitanyaILCR_0-1767879509896.png

 

ChaitanyaILCR_2-1767879559534.png

 

you can add your content in the what it will contain section

 

I tried this and it's working

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Ankur Bawiskar
Tera Patron

@manju12 

if user knows that he/she is changing password then why you want email to be sent.

this is not a valid business requirement.

If you still want then you can use Flow Designer with low-code, no-code approach for this

AnkurBawiskar_0-1767882208284.png

AnkurBawiskar_2-1767882281620.png

 

AnkurBawiskar_1-1767882265708.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Dr Atul G- LNG
Tera Patron

Hi @manju12 

 

You are creating technical debt by changing the password email. Now, if you want to send an email, the technical debt will remain, as users already know they changed the password. Please avoid this and educate the business instead.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************