- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 12:21 AM
I have to create a report which will show those cases which received email after getting case closed.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 03:15 AM - edited ‎06-11-2025 03:16 AM
// 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 12:57 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 02:25 AM - edited ‎06-11-2025 02:26 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 03:15 AM - edited ‎06-11-2025 03:16 AM
// 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 03:20 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader