Inbound action to update Case from a Froward email

Chris44
Kilo Explorer

Hi, 

We would like to be able to update Cases and Incidents from emails that have been forwarded. 

If an end user forwards an email with the watermark and ref number in the subject then we want the case or incident to be updated just like a reply email does. 

I have tried to create a new inbound action with the type set of forward and use the same code from the "Update Case via reply" but it doesn't update the case, instead it creates a new case. 

I would appreciate any help. 

 

 

12 REPLIES 12

Madhav18
Mega Expert

Hi Chris,

Please find the inbound action which is responsible for creating case and make sure your new inbound action order is less than that so that your update inbound executes first.

You can find the inbound action which is creating case using the email log of the test fwd email which you sent to service now.

Test again after making above change and also find about the execution of your new inbound action whether it's processed or skipped from the email log of the test fwd email which you sent to service now so that you can take appropriate action.


If it helps, please mark Correct and 👍 Helpful.


Thanks & Regards,
Madhav

Hi Madhav, The inbound action I have created is one of the first actions that is run, it's before the update case action and before the update from reply action. In fact it's the first action that has the type of forward. I think I need to code to UPDATE a case from a forwarded email, as the code from update case on reply doesn't work for a forwarded email. Thanks

Hi Chris,

The only difference in inbound actions for fwd and reply type email actions is Type field on When to run section of inbound action. I'm sure you kept that as Forward instead if Reply.

Coming to the Actions section of Inbound action, can you add any log statements to the code like gs.log() to find out from system logs (system logs-> system log-> All) whether inbound action is executing or not. 

Also can you share snapshot of email log from system logs -> emails and select the test email you send to instance and scroll down to see the email log. You should see something like in the pic below.
find_real_file.png

If it helps, please mark Correct and 👍 Helpful.


Thanks & Regards,
Madhav.

Hi Madhav, 

 

I have attached a screen shot of the email log. and also a copy of the code in the Email action that I have created. 

Hope this helps you see what I'm trying to do and what is not working. 

 

If there is anything else I can provide you with please let me know. 

 

Thanks

find_real_file.png

 

 

//if case.state = resloved (6), then check first word in body for accept or reject
//else if case.state = Awaiting (18), then, move to open state
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();