- 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 06:46 AM
Hi Sachin.
as created everything as suggested about , but no luck ,, email is not getting triggered.
gs.eventQueue('dabaseaccess.update1',current,current.u_access_description,'');
this is how am passsing the even queue
- 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-04-2020 02:53 AM
Hi Sachin,
Thank you so much for the quick response:)
it works as expected
Thanks a lot:)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 05:44 AM
Hi,
You can write a before or after business rule to trigger a notification on deletion of record.
Here you can refer the following links :
https://community.servicenow.com/community?id=community_blog&sys_id=2d6dea29dbd0dbc01dcaf3231f961956
Make it Correct or mark it helpful, if my response helps you.
Thanks
Bhagyashri Sorte
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 06:03 AM
Hey lavu,
Create an after delete business rule
Create an event on the table
Create an email notification on that table and associate the event with this email
fire the event from the BR and set the recipient
in Notification
In Event registry
you can refer this thread as well,
mark Correct and Helpful if applicable.
Regards,
Indrajit.