User interacts/sends mail to closed HR tasks then it should redirect him to create new case

ShahidaM
Tera Contributor

If user tried to interact with closed HR task via email then it should redirect him to create new case.How to achieve this functionality.can someone help me?

 

 

Thanks in advance

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @ShahidaM 

 

https://www.servicenow.com/community/hrsd-forum/new-hr-case-creation-from-the-email-sent-to-already-...

https://www.servicenow.com/community/csm-forum/how-to-create-a-new-case-when-anyone-replying-to-the-...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @ShahidaM 

 

Did you check these links?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

sunil maddheshi
Tera Guru

@ShahidaM 

you may need to handle email replies to closed HR tasks and redirect to create a new HR case when a user attempts to interact with a closed task.

your email inbound script should be something like this

// Get the HR Task from the email
var hrTaskSysId = email.related_sys_id;

if (hrTaskSysId) {
    var hrTask = new GlideRecord('sn_hr_core_task');
    if (hrTask.get(hrTaskSysId)) {
        if (hrTask.state == 3 || hrTask.state == 4 || hrTask.state == 7) { // Closed states

            gs.info("HR Task is closed. Sending redirect email.");

            // Construct the HR case creation link
            var portalUrl = gs.getProperty("glide.app.service_portal.url");
            var createCaseUrl = portalUrl + "/sp?id=sc_cat_item&sys_id=<YOUR_CATALOG_ITEM_SYS_ID>";

            // Send email response
            var emailUtil = new GlideEmailOutbound();
            emailUtil.setSubject("HR Task Closed - Create a New Case");
            emailUtil.setBody("The HR task you replied to is closed. If you need further assistance, please create a new HR case here: " + createCaseUrl);
            emailUtil.setTo(email.from);
            emailUtil.send();
        }
    }
}

Please mark correct/helpful if this helps you!

Do I need to write Inbound emai on HR task table ?please help if all the details are updated correcctly.

 

ShahidaM_1-1742823978947.png