How to link an email to the appropriate incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 06:13 AM
If the incident is not resolved or not closed, I need to
- link the inbound email to the appropriate incident,
- Add the reply email (only) to the work-notes within.
Any help would be appreciated.
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 10:30 AM
This is how i modified some parts, is it correct?
if (current.state != "6" && current.state != "7")//incident not resolved or closed
{
//Add the reply email (only) to the work-notes within.
current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
return;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 10:32 AM
Hi Soni,
if (current.state != "6" && current.state != "7")//incident not resolved or closed
{
current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
}
This should work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 10:34 AM
Can you paste the whole code here once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 10:36 AM
this is what I've done so far:
gs.include('validators');
(function(){
//var bodyText = email.body_text;
if (current.getTableName() == "incident") {
if(current.state == "6" || current.state == "7")//incident is not resolved or closed
{
gs.eventQueue("Inbound_Email(Incident_resolved)",current,current.caller, gs.getUserID());
return;
}
if (current.state != "6" && current.state != "7")//incident not resolved or closed
{
//Link the inbound email to the appropriate incident.
//Add the reply email (only) to the work-notes within.
current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
}
if(current.assigned_to !=""){
gs.eventQueue("Notification to assigned to analyst",current,current.assigned_to, gs.getUserName());}
else if (current.assigned_to ==""){
gs.eventQueue("Assign To analyst is blank",current,current.
assignment_group.Incident.Coordinator, gs.getUserName());
return;}
//if incident state awaiting / awaiting user info
if(current.state=="11" && current.u_substate=="4")
{
current.state="1";
current.update();
return;
}
//if task state is response required
var gr=new GlideRecord('u_inc_task');
gr.addQuery('response required',true);
gr.query();
while (gr.next())
{
if(current.state=="-1")
{
current.state="1";
current.update();
return;
}
}
//If an inbound email is sent to ServiceNow that does not have the proper identification
var sender=email.from;
if(sender != undefined)
{
gs.eventQueue("No proper identification",current,current.caller, gs.getUserID());
return;
}
//}
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 10:41 AM
Hi Soni,
Try to put this in script include and call it from the inbound email action. Put log statement and check which line is causing the issue.
It will give you clear idea.