Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Send email on user deletion

neelamallik
Tera Contributor
I'm unable to see email sent to user after deletion in Notifications > emails, please have a look at this issue
 
(function executeRule(current, previous /*null when async*/) {

    var mail = new GlideEmailOutbound();
    mail.setSubject("User Deleted: " + current.name);
    mail.setTo("admin@example.com");
    mail.setBody("User " + current.name + " with Sys ID " + current.sys_id + "was deleted.");
    mail.send();

})(current, previous);
3 ACCEPTED SOLUTIONS

Its_Azar
Kilo Sage

hi there @neelamallik 

Not the right way, using GlideEmailOutbound() directly in a Business Rule is not great. The better approach is to queue an event in a Before Delete rule using gs.eventQueue() and then create a Notification triggered by that event. This is the standard ServiceNow method and ensures the email appears correctly under System Mailboxes > Outbound > Sent.

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,
Azar
Serivenow Rising Star
Developer @ KPMG.

View solution in original post

Hi @neelamallik , Did your requirement got resolved? Where are stuck now?

If this response helped resolve your issue, please consider marking it as Accepted Solution and giving it a thumbs up.
This helps others in the community find useful answers more easily.

Regards,
Saurabh V.

View solution in original post

Hi @neelamallik , Hope you're doing well, did you got the solution?

 

If my previous response helped resolve your issue, please consider marking it as Accepted Solution and giving it a thumbs up.
This helps others in the community find useful answers more easily.

Regards,
Saurabh V.

 

View solution in original post

7 REPLIES 7

Tanushree Maiti
Giga Sage

Hi @neelamallik 

 

It seems you are using After Delete business rule. The time you are sending notification gs.eventQueue(), that time current object is getting deleted.

 

So you have to use Before Delete Business Rule in order to get Notification email script work properly.

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Ankur Bawiskar
Tera Patron

@neelamallik 

since record is deleted after delete BR won't work

check this link

How to Properly Send an Email Notification When a Record Is Deleted in ServiceNow 

💡 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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@neelamallik 

Hope you are doing good.

Did my reply answer your question?

💡 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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader