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

Ok. Must be a business rule which is moving it back to Awaiting.try this



gs.include('validators');


if (current.getTableName() == "hr_case" && current.state == 3) {


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


}


if (current.state == 20)


{


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


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


}


//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.

no - same thing - keeps being moved to awaiting acceptance.. I looked at BRs and nothing catches my eye that would be pushing the state back to awaiting acceptance from an inbound email.



thanks,


-Rob


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.

okay - And I agree - i keep looking at the inbound action and was wondering why that was happening.


thanks so much for all your help!


I will investigate this out more.


-Rob


Hey Sanjiv, found it!



the business rule was called ' Add User Acceptance State'



the business rule script has:


function onBefore(current, previous) {


current.state =   SMConstants.ORDER_AWAITING_USER_ACCEPTANCE;


}



I deactivated that one, tested the inbound again with your latest script to me, and the email was recorded without moving case back to awaiting acceptance state.


Now i just need to make sure that BR isn't going to mess anything else up.



Thanks,


-Rob