- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2022 12:40 AM
Hello Experts,
I have a requirement where in User is Sending Email for the already closed HR Case.
Right now we have a Function where the reply is getting recorded as Comment in the Case.
I need to implement the solution where in a new HR Case is getting created in the above scenario and also no Comment is added to already Existing HR Case.
Kindly provide some guidelines on how to do it.
Regards,
TM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2022 07:38 AM
Hi,
There is a good article from ServiceNow itself on the same topic on how to handle this. Please see the comments below:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0794209
Use the following logic to add an inbound email action on a Business Rule:
// Where 6 is the value of your resolved state
if (current.state == 6) {
//Your inbound code here
}
if (current.active == false) {
// Activate a ticket is closed event if active is false (closed)
gs.eventQueue("ticket.closed", current, current.state, previous.state);
}
If the CASE/Incident is closed you can fire an event, which sends an email.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2022 07:31 AM
Hi,
Another way is would be to create a notification that bounce when someone trying to update a closed case, in that notification you can direct them to the portal and stating they are trying to update a closed case, please submit another one.
/Markus
Markus Nilsson
+46709389974
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2022 07:38 AM
Hi,
There is a good article from ServiceNow itself on the same topic on how to handle this. Please see the comments below:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0794209
Use the following logic to add an inbound email action on a Business Rule:
// Where 6 is the value of your resolved state
if (current.state == 6) {
//Your inbound code here
}
if (current.active == false) {
// Activate a ticket is closed event if active is false (closed)
gs.eventQueue("ticket.closed", current, current.state, previous.state);
}
If the CASE/Incident is closed you can fire an event, which sends an email.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 02:54 AM
Thank you for the reply..Requirement is to create a new case
I am using below Code
var checkState = new GlideRecord('sn_hr_core_case');
checkState.addQuery('number',current.number);
checkState.addQuery('state','closed');
checkState.query();
if(checkState.next())
{
var newCase = new GlideRecord('sn_hr_core_case');
newCase.initialize();
newCase.field_values = checkState.field_values;
newCase.insert();
}
This is not working.
Regards,
TM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 08:22 AM
Hi,
Where are you writing this piece of code?
I would suggest you can update the existing Inbound action and within this we can create a new HR Case when some one tries to update a Closed Case as shown below:
Navigate to the below URL:
https://instance.service-now.com/nav_to.do?uri=sysevent_in_email_action.do?sys_id=7a5370019f22120047a2d126c42e7063
Replace "instance' with your instance name.
Use the script as below:
gs.include('validators');
if (current.getTableName() == "sn_hr_core_case") {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
if (current.getTableName() == 'sn_hr_core_case' && current.state == 3) {
createNewHRCase(current);
}
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
current.update();
}
function createNewHRCase(current) {
var gr = new GlideRecord('sn_hr_core_case');
gr.initialize();
gr.FIELD_NAME = current.FIELD_Name;
gr.insert();
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke