How to identify new email coming to closed cases in customerservice_Case.

Vinay Chaurasia
Tera Contributor

I have to create a report which will show those cases which received email after getting case closed.

1 ACCEPTED SOLUTION

// Get the email subject and body
var subject = email.subject;
var body = email.body_text;

// Look for a ticket number in the subject (e.g., INC0000001)
var regex = /INC\d{7}/;
var match = regex.exec(subject);

if (match) {
  // A ticket number was found
  var ticketNumber = match[0];
  var incidentGR = new GlideRecord('incident');
  incidentGR.addQuery('number', ticketNumber);
incidentGR.addQuery('state','7'); // please add state of closed
  incidentGR.query();

  if (incidentGR.next()) {
    // Incident found, update its comments
    incidentGR.count = incidentGR.getValue('count')+1;
    incidentGR.update();
  } 
}

 

Use the above code inbound action.
create a new field in the table update the same in the code, and update table names as well.

View solution in original post

4 REPLIES 4

Anil Nemmikanti
Giga Guru

Hi @Vinay Chaurasia ,

As per my knowledge, I think OOTB there is no feature to identify that but you can create a new field on the table to add the count and you can create a Inbound action which will update the count.

Please let me know any help required to with Inbound action.

Please confirm that count will be updated only when email received for closed cases. It will be highly appreciated if you can help on inbound action too.

// Get the email subject and body
var subject = email.subject;
var body = email.body_text;

// Look for a ticket number in the subject (e.g., INC0000001)
var regex = /INC\d{7}/;
var match = regex.exec(subject);

if (match) {
  // A ticket number was found
  var ticketNumber = match[0];
  var incidentGR = new GlideRecord('incident');
  incidentGR.addQuery('number', ticketNumber);
incidentGR.addQuery('state','7'); // please add state of closed
  incidentGR.query();

  if (incidentGR.next()) {
    // Incident found, update its comments
    incidentGR.count = incidentGR.getValue('count')+1;
    incidentGR.update();
  } 
}

 

Use the above code inbound action.
create a new field in the table update the same in the code, and update table names as well.

Ankur Bawiskar
Tera Patron
Tera Patron

@Vinay Chaurasia 

there is nothing available out of the box for this.

You can use a true/false hidden field on Case and whenever Inbound email is triggered and if email came for target case which is Closed/Inactive, then update that flag as True

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader