The CreatorCon Call for Content is officially open! Get started here.

email reopens the HR case

Vinya Jakkula
Tera Contributor

Hi Team,

Could anyone help me with this? When users respond to an HR case after 1 year, the case currently reopens. Instead, I need to stop it from reopening and automatically create a new ticket. How can I achieve this?

4 REPLIES 4

Rafael Batistot
Kilo Patron

Hi @Vinya Jakkula 

 

You need to update the code that reopen the hr case after 1 year, if you create a new one probably that this behavior will continue. 

Kindly sheared the code or the flow that have this behavior? 

If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.

Ankur Bawiskar
Tera Patron
Tera Patron

@Vinya Jakkula 

you can identify which OOTB Inbound action is reopening and comment the code which updates, write your own script to insert new HR Case.

what did you try and where are you stuck?

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

M Iftikhar
Tera Sage

Hi Vinya,

By default, ServiceNow reopens the closed HR case when users reply via email. To stop this and instead create a new case, update the Inbound Email Action handling HR cases:

  1. Go to System Mailboxes > Inbound > Inbound Actions.

  2. Open the action that processes replies to HR cases (identify via subject or queue).

  3. Uncheck Reopen closed record.

  4. Ensure the action is set to Create New Record.

Now, replies to old closed cases will generate new tickets instead of reopening the old one. Make sure to test in a sub-prod instance first.

Hope this helps!
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.

 

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

kaushal_snow
Mega Sage

Hi @Vinya Jakkula ,

 

To prevent a closed HR case from reopening after 1 year when the user responds, and instead have a new case created doable with some customization... The key is to customize the Inbound Email Action (or Flow/Email processing logic) to check the closure date, and depending on age, either reopen or spin up a new HR Case....

 

Add logic in the action / a script to check how long the case has been closed....

var caseGR = new GlideRecord('sn_hr_core_case');
caseGR.addQuery('sys_id', email.thread_topic || subject reference); // find the related case
caseGR.query();
if (caseGR.next()) {
var closedDate = caseGR.closed_at; // or equivalent field
if (closedDate) {
var now = new GlideDateTime();
var diff = GlideDateTime.subtract(now, closedDate);
// Example: one year ~ 365 days
if (diff.getDays() >= 365) {
// Create a new HR Case
var newCase = new GlideRecord('sn_hr_core_case');
newCase.initialize();
newCase.short_description = caseGR.short_description;
newCase.description = email.body_text; // or mapping
newCase.opened_for = caseGR.opened_for;
// set other required fields
newCase.insert();
} else {
// Less than 1 year > just reopen the existing case
caseGR.state = 'open'; // whatever your open state is
caseGR.update();
}
} else {
// If case wasn't closed properly, treat as for reopening or always new
caseGR.state = 'open';
caseGR.update();
}
}

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/