- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 05:24 AM
Hi Team,
Can someone help me how to trigger notification when record is deleted from table???
the notification should contain details of the deleted record also.
any help would be appreciated,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2020 12:43 AM
Hi,
I realized that we shouldn't use the 'current' object in gs.event method, since before the event triggers that record is getting deleted and so current object not holds any data about record.
Please follow the below, I have tested it in my personal instance and working fine.
- We need to set all required record details in a json object, and use that object in event parm1 field.
- We need to create notification mail script to extract the field details from even
- Add the mailscript in your notification template.
In Before Delete BR wirte code as below
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var obj ={
"number":current.number.toString(),
"shortDescription": current.short_description.toString()
};
var content = JSON.stringify(obj);
gs.eventQueue('record.inc.delete',null,content,'','');
})(current, previous);
Create Notification mail script as below.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var jsonObject = JSON.parse(event.parm1);
template.print('Incident Number: '+ jsonObject.number);
template.print('Incident ShortDescription: '+ jsonObject.shortDescription);
})(current, template, email, email_action, event);
Add the mail script in Notification template as below.
${mail_script:delete_record_content}
please mark it correct/helpful, if it answers your query,
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 05:42 AM
Create a event on your table
Create a notification and listen to this event.
Then write before delete Business Rule on your table and trigger an event with the current object.
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 08:01 AM
Use Before Delete, so that the current record is available in your notification and you can get the information.
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 05:44 AM
Hi,
1) Create Business Rule, When to Run condition as below,
2) In Advance section, use gs.eventQueue('eventName',current object, parm1, parm2); method
Note: i have set Parm1 has assignment group of current record.
3) Create an event 'record.delete.notif' in System policy-->Events-->Registry.
4) Create Notification, with When to send should be "event fired" and give event name as 'record.delete.notif'.
a) Whom to send, you can select "Event Parm1"
b)what it cotains, Use the current object access the record fields.
Please Mark it correct/helpful, If it answers your query.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 05:46 AM
Hi,
Business Rule Should be "Before Delete"
Regards,
Sachin