Need help on Inbound Actions Script

Bird1
Mega Sage

Currently, we're using Inbound Action: Update HR Case to update the ticket's state and comment. But we do have requirement if the HR case is already inactive, it should trigger the event to send auto reply message to sender.

 

Problem is I am not sure how to check the active true/false of HR case. I thought about using current.active == true and current.active == false but it seems the current.active in the script, it checks the email instead of HR case.

 

Can anyone please help?

 

gs.include('validators');

if (current.getTableName() == "sn_hr_core_case") {
    current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;

	if (current.active == true){ 

    if (email.body.assign != undefined)
        current.assigned_to = email.body.assign;

    if (email.origemail == current.opened_for.email || email.origemail == current.u_sender_email.toString())
	{
		var emailsubject = email.subject.toString().toLowerCase();
        if (emailsubject.indexOf("accepted") >= 0 && current.state == 20)
		{
			current.state = "3"; // closed completed
		}

        if (email.subject.indexOf("rejected") >= 0 && current.state == 20)
		{
            current.state = "18"; // work in progress
		}
    }
	}

	else if (current.active == false){
		
		if((email.origemail.toLowerCase().indexOf('abc.com') > -1) || (email.origemail.toLowerCase().indexOf('def.com') > -1))
		{
           gs.eventQueue('sn_hr_core.internalautoreply', current, email.origemail, current.number);
		}
		else if((email.origemail.toLowerCase().indexOf('abc.com') == -1) && (email.origemail.toLowerCase().indexOf('def.com') == -1))
		{
           gs.eventQueue('sn_hr_core.externalautoreply', current, email.origemail, current.number);
		}
	}

    current.update();
}