Event Fired with Mail Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2016 05:02 AM
Hi All,
I have an Requirement
Event:When the Additional comment section is updated before reaching the Finalized state.
Email Recipient: Approvor (The email should have a link to the RITM.)
I want to set an event and trigger a mail to approver list after updating the Additional comment field in RITM Table.
Thanks
Sukant
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2016 05:10 AM
Below link will help you.
http://wiki.servicenow.com/index.php?title=Events_and_Email_Notification#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2016 05:46 AM
1) Create event in event registry. ( Go to System Policy | Registry )
Name: ritm_approver_email Table: sc_req_item
2) Create a business rule that fires an event onChange of the comments field.
Name:BR-FireNotificationEventToApprover
Table: sc_req_item
Filter Condition: Additional Comments Changes and State is not Closed Complete, Closed Incomplete, Closed Skipped.
Tick the "Update" to indicate it should run on an update.
Script:
(function executeRule(current, previous /*null when async*/) {
var approver_array = [];
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.query();
gs.log('count: ' + gr.getRowCount());
while (gr.next()) {
approver_array.push(gr.sys_id.toString());
gs.log('what is approver array' + approver_array);
}
// Name of Event, Current Record, Parm 1, Parm 2.
gs.eventQueue("ritm_approver_email", current, approver_array, approver_array);
})(current, previous);
3) Lastly, set up a notification that sends on an event, select event ritm_approver_email. For recipients of the email, select Parm 1 or Parm 2. That will send to all approvers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2017 12:26 PM
Hi Phillip,
Thanks for sharing your solution. It worked with the exception of the script on the business rule. Here is my working code:
(function onAfter(current, previous /*null when async*/) {
var approver_array = [];
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('state','=','requested');
gr.query();
gs.log('count: ' + gr.getRowCount());
while (gr.next()) {
approver_array.push(gr.approver.toString()); <--- I updated this line
gs.log('what is approver array' + approver_array);
}
// Name of Event, Current Record, Parm 1, Parm 2.
gs.eventQueue("ritm_approver_email", current, approver_array, approver_array);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2016 06:05 AM
Hi Sukanta,
Goran wrote a blog on firing email notifications that should be helpful. Check out his blog here.
Please mark this answer correct if it is helpful.
Thanks.