Inbound Action - Update Case Via Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 02:20 AM
Hi
What would I need to add to the following so that if the case is resolved (6) but Accept or Reject does not appear on the first line then just set the status back to Open (10).
The Awaiting should stay as it is.
Thanks in advance.
Richard
//if case.state = resolved (6), then check first word in body for accept or reject
//else if case.state = Awaiting (18), then, move to open state
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text ;
var case_state = current.state;
if (current.state == 6) {
var lines = email.body_text.split('\n');
var firstword = "";
if (lines.length > 0)
firstword = lines[0].replace(/^\s+|\s+$/g,'');
firstline = firstword.toLowerCase();
if (firstline) {
if(firstline.indexOf("reject") == 0)
current.state = 10;
else if(firstline.indexOf("accept") == 0)
current.state = 3;
}
} else if (current.state == 18) {
current.state = 10;
} else{
current.sys_updated_on = "";
}
current.update();
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 04:42 AM
Hi Richard,
Please keep in mind that if indexOf() doesn't find what it is looking for it returns -1.
As I read your code, once you have at least one line in the body of the email and it does not start with reject, you set the state back to open. You might want to change the examination of that line to something like:
if (firstline.indexOf("reject") == -1 && firstline.indexOf("accept") == -1)
current.state = 10;
Hope that helps.
:{)
:{)
Helpful and Correct tags are appreciated and help others to find information faster

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 05:20 AM
HI,
Can you give a snap shot of Subject line and Body?
Thanks,
Ashutosh