Recording incoming reply emails to closed cases

Rob Sestito
Mega Sage

Hello SN Comm,

Looking for some scripting help.. I have an inbound email action that I am looking to control a little more.

as of right now, my current inbound email action is called HR Case Update. It helps control incoming emails to NOT change the state of a Case as it was doing before. It also helps control the Accept / Reject Email Notification replies to cases. We have ready but not in prod yet, an email notification that is sent to the end user once a Case worker clicks on 'Resolve Case' button, and sends the Case to 'Awaiting acceptance' state, which triggers the email notification to be sent. To allow the end user to click on one of two URL links to accept or reject the resolution to their case.

With the current inbound email action, it does not record incoming emails when the Case is in 'Closed Complete' (inactive state). I would like to see about modifying this to allow the email to still be recorded when the Case is closed.

Here below is the current inbound email script: (3 = closed completed / 20 = awaiting acceptance / 18 = work in progress)

gs.include('validators');

if (current.getTableName() == "hr_case") {

current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;

}

if(current.state !=3){

if (current.state == 20)

{

//Awaiting Acceptance

if (email.subject.indexOf("Accept") >= 0){

current.state = 3; //Close Complete

}

if (email.subject.indexOf("Reject") >= 0){

current.state = 18; // Work in Progress

}

current.update();

}

}

thanks in advance, hope someone can help out!

-Rob

1 ACCEPTED SOLUTION

I dont see anything in the inbound that could move it back to Awaiting Acceptance. There must be a business rule, which changes back to Awaiting acceptance. If it is dev environment, you may try deactivating all the BR and try again. Note down the BR you are deactivating.



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

11 REPLIES 11

SanjivMeher
Kilo Patron
Kilo Patron

Try the below code.



gs.include('validators');


if (current.getTableName() == "hr_case") {


current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;


}


if (current.state == 20)


{


//Awaiting Acceptance


if (email.subject.indexOf("Accept") >= 0){


current.state = 3; //Close Complete


}


if (email.subject.indexOf("Reject") >= 0){


current.state = 18; // Work in Progress


}


current.update();


}



Please mark this response as correct or helpful if it assisted you with your question.

Thanks for your reply Sanjiv,



Unfortunately an incoming email is still not being recorded to the closed case.


Thanks,


-Rob


Ok. I maade a correction. Please try now



gs.include('validators');


if (current.getTableName() == "hr_case") {


current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;


}


if (current.state == 20)


{


//Awaiting Acceptance


if (email.subject.indexOf("Accept") >= 0){


current.state = 3; //Close Complete


}


if (email.subject.indexOf("Reject") >= 0){


current.state = 18; // Work in Progress


}


}


current.update();



Please mark this response as correct or helpful if it assisted you with your question.

So that worked - however, it then also pushed the closed case back to 'Awaiting Acceptance' state. which is not what I want this to be able to do. If a closed case gets an email reply to it, I just need it to record the email, without throwing it back to an active state.



thanks,


-Rob