how to link emails to incidents using the INC reference

Dubz
Mega Sage

Hi,

Just wondering if anyone can advise me on the script i would require to have new emails update a current incident if they have the INC reference in the subject line? We have various customers who communicate with us using their own ticketing systems so Service Now classifies their emails as new. We can get them to add the INC reference to the subject line but SN will only use that to update a current incident if the email is classified as a reply.

1 ACCEPTED SOLUTION

David,



Can you share the subject line you used?


Ideally if it contains INCxxxxxxx it should process the script since the condition meets.



Also change the script to following, this should update your short description to the email body text and ends processing of inbound mail against other email actions.



gs.include('validators');


if (current.getTableName() == "incident")


{


  var index = email.subject.indexOf("INC");


  var incNumber = email.subject.substring(index,index+10);


  gs.log(incNumber,'test');



  var gr = new GlideRecord('incident');


  gr.addQuery('number',incNumber);


  gr.query();



  while(gr.next())


  {


gr.short_description = email.body_text;


  gr.update();


event.state="stop_processing";


  }


}


View solution in original post

11 REPLIES 11

@test1 test11 Surely I can help, you can use flow designer here which is quite a user-friendly tool to run these actions. If you are stuck, post your code or flow designer and I will try to fix it. 

 

Thanks, 
Harneet

GB14
Kilo Patron

@Harneet Sital  I have used your script above and it does update the incident but It also creates a new incident at the same time. Any idea why an incident is being created? I verified the Tigger order, and logs show the same action is creating a new incident and also updating the older record. 

 

GB14_2-1694098395219.png

 

 

GB14_1-1694098365055.png

 


We have the inbound Action Type set to NONE as the vendor emails have many different types of subject lines.

 

Thanks in advance. 
G