Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to update existing incident ticket using inbound email action

String
Kilo Sage

Hi Team ,

Am using below code to update the existing incident records using inbound email action ,instead of updating ,service now creating  a new incident .below is my code 

 

 var caseGR = new GlideRecord(‘incident’);

 var Number = emailBody.incident_ticket;

caseGR.addQuery('number', Number);

caseGR.query();

if (caseGR.next()) {

 current.state = 10;

current.description='Reopen ticket';

   current.update();

}

am trying to use  current.update(); instead of caseGR.update(); because I want to capture email in activity log (incident )

 

Please guide me with best practices 

5 REPLIES 5

Community Alums
Not applicable

For anyone else landing here from searching, switching current to the record you want should cause the email to attach to it in the activity log:

if (caseGr.next()) {
...
caseGr.update();
current.get(caseGr.sys_id); // Switch current so the email is attached to it
}