Inbound Email Action condition needed

Rob Sestito
Mega Sage

Hello SN Comm,

I have an Inbound Email Action to update an HR Case when it is in Pending Customer state.

When to run tab:

Type: Reply

Conditions: (Currently nothing)

Actions tab:

Field actions: State TO Work in Progress

Script:

gs.include('validators');

// Pending Customer Case moves to WIP from incoming email by customer

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

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

if (email.body.assign != undefined)

current.assigned_to = email.body.assign;

}

***************************************

Want/need:

I want to have the ability for this Inbound Action to trigger ONLY when the email reply is someone attached to the Case (Example: if the reply coming in is the Requested For/ Caller)

I do NOT want this Inbound Email action to trigger if someone not working on the Case emails in to it (Example: if the reply coming in is a Manager of the group that the Case is assigned to, etc).

Mainly because when the Case state is in Pending Customer, the Customer is the one that needs to provide information. This is why I would like the Inbound Action to be triggered when the Customer emails back in to the Case.

Does this request make sense? I looked through the Conditions under When to run tab and none available seem to be what I need for this.

Hopefully I have explained this well enough to receive some help.

Any help is greatly appreciated!

Cheers,

-Rob

1 ACCEPTED SOLUTION

Rob Sestito
Mega Sage

Thanks everyone for your help on this!



I was able to configure the script to how I needed it, here is what I have:



gs.include('validators');


var userAddr = email.from;


gs.log("User email: " + userAddr);


// Update work notes regardless of who sends email


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



if (email.body.assign != undefined)


current.assigned_to = email.body.assign;



// Pending Customer Case moves to WIP from incoming email by requestor/requested for


if (current.getTableName() == "hr_case" && current.state == 8 && (current.caller.email == userAddr || current.opened_for.email == userAddr)) {


current.state = 18;


}


// Update case


current.update();



Inbound action records the incoming emails to Case Activity, all while NOT changing the State back to WIP UNLESS the email comes from Requestor/Requested For.



Thanks again for the help here!!



Cheers,


-Rob


View solution in original post

6 REPLIES 6

Thanks a lot Fredrik,



I will have a chance today to go over this with my SN Teammate that is an Admin like I (but better at scripting right now), and see what we can do!


I very much appreciate your help here!



Cheers,


-Rob


Rob Sestito
Mega Sage

Thanks everyone for your help on this!



I was able to configure the script to how I needed it, here is what I have:



gs.include('validators');


var userAddr = email.from;


gs.log("User email: " + userAddr);


// Update work notes regardless of who sends email


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



if (email.body.assign != undefined)


current.assigned_to = email.body.assign;



// Pending Customer Case moves to WIP from incoming email by requestor/requested for


if (current.getTableName() == "hr_case" && current.state == 8 && (current.caller.email == userAddr || current.opened_for.email == userAddr)) {


current.state = 18;


}


// Update case


current.update();



Inbound action records the incoming emails to Case Activity, all while NOT changing the State back to WIP UNLESS the email comes from Requestor/Requested For.



Thanks again for the help here!!



Cheers,


-Rob