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

svirkar420
Tera Guru

 Hi @neelamallik ,

The email is not visible because sending mail directly using GlideEmailOutbound from a delete Business Rule is not the recommended or reliable approach.

When a record is deleted, the best practice is to trigger an event and send the email through a Notification. This ensures the email is properly queued, processed by the platform, and logged in the system email tables.

ServiceNow can still access the record values during deletion, so the email can be sent successfully when implemented using the event-driven notification framework.

 

Step 1: Create a Business Rule on before or after delete and trigger an event.

Step 2: Register a custom event for the deletion action.

Step 3: Create a Notification that is triggered by the event and configure the recipients and message content with details of the deleted user.

 

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

Regards,
Saurabh V.

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.

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.

 

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.