- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 08:31 AM
We'd like to send auto replies to users who reply directly to an incident resolve email instead of using the reopen link as well as any replies to incidents that are closed. There's topic I found that goes into some detail how to do this but we'd like to auto-reply to the person that sent the email rather than assume it is the caller because of the way we use the watch list. Has anyone done this before?
Thanks,
Aryanos
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 02:53 PM
Aryanos,
In your script change to some thing like this:
gs.eventQueue("incident.closed.autoreply", current, email.origemail, '');
The error you are getting is because, previous.state is not defined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 01:54 PM
Aryanos,
I didn't find your original post about an error for email.origeemail. Can you post it again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 02:09 PM
Hi Mani,
It was an error that I corrected so I removed it. After some testing I'm noticing my event is not triggering and not sending an email. I created a business rule called Auto-Reply notifications to trigger the event and this is what I have in the code but not sure if it's correct.
When: After Update
if(current.active == false)
{
gs.eventQueue("incident.closed.autoreply", current, email.origemail, '');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 02:25 PM
Aryanos,
You should not create business rule on the Incident table as you don't know the person who is sending the email at that time.
Thats why you need to do like this:
There will be an Inbound Action 'Update Incident (BP)' which has a script like:
gs.include('validators');
if (current.getTableName() == "incident") {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
if (email.subject.toLowerCase().indexOf("please reopen") >= 0) {
current.incident_state = "2";
current.work_notes = "The caller did not feel that this issue was resolved";
}
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
if (email.body.priority != undefined && isNumeric(email.body.priority))
current.priority = email.body.priority;
if (email.body.category != undefined)
current.category = email.body.category;
if (email.body.short_description != undefined)
current.short_description = email.body.short_description;
current.update();
}
This above Inbound action is responsible for updating the comments on the Incident when somebody replys back.
In this have a script something like:
if(current.active == false){
//auto-reply notification to caller
gs.eventQueue("incident.closed.autoreply", current, email.origemail, previous.state);
current.comments('User replied to a Closed incident. Auto-reply notification sent to the user');
}
Now in your Email Notification, mark the 'Event Parm 1 contains recipient' as true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 02:38 PM
Hi Mani,
Yea, I wasn't sure about the business rule as the Events and Email Notification Events and Email Notification - ServiceNow Wiki said we needed to have one but the gs.eventQueue in the inbound email action should invoke it. I have that set in my email notifications for the Event Parm 1 field. Here's my Update Incident (BP) in bound action script:
gs.include('validators');
if (current.getTableName() == "incident") {
//current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
if(current.state == 6){
if (email.subject.toLowerCase().indexOf("please reopen") >= 0) {
current.incident_state = "2";
current.work_notes = "The caller did not feel that this issue was resolved";
}
//direct reply from email without using link
else{
gs.eventQueue("incident.nodirectreply", current, email.origemail, previous.state);
current.work_notes = "User replied directly from the resolve email notification. Auto-reply notification sent to the user";
}
current.update();
}
if(current.active == false){
//auto-reply notification to caller
gs.eventQueue("incident.closed.autoreply", current, email.origemail, previous.state);
current.work_notes = "User replied to a Closed incident. Auto-reply notification sent to the user";
current.update();
}
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2015 02:43 PM
So, is this script worked? If so can you mark the post as answered.