How to trigger an event for outgoing emails
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2016 06:02 AM
Notifications to a watch list can be set up for incident.commented and incident.updated (events defined in the OOB business rule) but emails sent from within an incident are not treated as comments or updates so do not trigger either event and their associated notification. What I am struggling to find is what to put into the business rule to cause an outgoing email added to the activity stream of an incident to fire an event. Has anyone else managed to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2018 11:43 AM
If you are looking to trigger an event when the "email client" feature is used to communicate with the end user (and only the email client feature), you can create the following business rule:
Here is the advanced code:
function onBefore(current, previous) {
//Set the Last User Update Provided Field.
var incGr = new GlideRecord('incident');
if(incGr.get(current.instance)){
var EndUserEmailed = false;
var to = current.recipients.toString().toLowerCase();
var cc = current.copied.toString().toLowerCase();
var requestedByEmail = incGr.u_requested_by.email;
var requestedForEmail = incGr.caller_id.email;
if(to.indexOf(requestedForEmail) >= 0){
EndUserEmailed = true;
}
if(to.indexOf(requestedByEmail) >= 0){
EndUserEmailed = true;
}
if(cc.indexOf(requestedForEmail) >= 0){
EndUserEmailed = true;
}
if(cc.indexOf(requestedByEmail) >= 0){
EndUserEmailed = true;
}
if(EndUserEmailed){
//Set Last Update Provided Date
var nowDate = new GlideDateTime(gs.nowDateTime());
incGr.u_last_user_update_provided_date = nowDate;
//Set Next Update Provided Date to 7 days later.
var nextUpdateDate = new GlideDateTime(nowDate);
nextUpdateDate.addDays(7);
incGr.u_next_user_update_due_date = nextUpdateDate;
//Update Incident
incGr.update();
}
}
}