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

Harneet Sital
Mega Sage
Mega Sage

Hi David,



I tried your scenario and this is working for me. I guess there might be little changes that might you need to make according to your cases but this script works perfectly.



Create a new inbound action on the incident table as below :



find_real_file.png



In the script use the following :



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.u_description = email.body_text;


  gr.update();


  }


}



Please let me know if you need any further help.


Hi David,



Maybe you could ask your customers to use a specific unique prefix in the subject of their emails. In the email properties you could add those prefixes to the


"Identify email as reply by these subject prefixes" property (glide.email.reply_subject_prefix).



Kind regards,


Paul


Interesting idea Paul, the only trouble is getting customers to do the things i need them to, they're notoriously unreliable. I need Service Now to parse the whole subject line as customers are wont to add references anywhere and everywhere!


Thanks Harneet, that doesn't seem to be working in my case, perhaps it needs some tweaking somewhere. Thanks for the response though.