Updating an Incident via email using INC number in Subject (No WaterMark)

Derek3
Kilo Expert

Hi,

We have a 3rd Party vendor who emails updates to our system, which include our INC number and a description in the Subject (and body) of what the Update should do, on hold, close etc.

As the email has no Watermark, is there a way of getting the Inbound Email action to check the Email, read the INC number and update the Incident by status.

Example email subject below and the emails will always come from the same address.

INC0010284 - Incident on Hold at 24/11/2014 20:02:30

I am relatively new to ServiceNow and have had a go, but sadly with no success.   Any ideas would be great.


Thanks

Derek

1 ACCEPTED SOLUTION

Yeah, it would be



var emailState = false;


if(email.subject.indexOf('On Hold') > -1)


      emailState = true;



var incNum = email.subject.substring(0,10);


var inc = new GlideRecord('incident');


inc.addQuery('number', incNum);


inc.query();


if(inc.next()){


    inc.comments = email.body;


    if(emailState == true)


                  inc.incident_state = 'Pending';


    inc.update();


}


View solution in original post

8 REPLIES 8

Mike Allen
Mega Sage

Query the incident table for something like



var incNum = email.subject.substring(0,10);


var inc = new GlideRecord('incident');


inc.addQuery('number', incNum);


inc.query();


if(inc.next()){


    inc.comments = email.body;


    inc.update();


}



or whatever.   Something like that.



Put it in an inbound email action.


Thanks, Mike.   That allows me update the Correct Incident with the email subject.   Is there a way of look at the rest of the subject and when it sees On Hold, allow me set the Incident State to Pending.


Yeah, it would be



var emailState = false;


if(email.subject.indexOf('On Hold') > -1)


      emailState = true;



var incNum = email.subject.substring(0,10);


var inc = new GlideRecord('incident');


inc.addQuery('number', incNum);


inc.query();


if(inc.next()){


    inc.comments = email.body;


    if(emailState == true)


                  inc.incident_state = 'Pending';


    inc.update();


}


Your usage may vary depending on your field names.   Pending probably has a number value.   If it does, use that instead of 'Pending'.