Reply and Forward Inbound email actions

karthikdoure
Mega Contributor

I would like to write a single inbound email action for the following three scenarios.

1. Reply email (Obviously has watermark)

2. Forward email with watermark

3. Forward email without watermark

By default, inbound emails of the Forward type always generate new incidents regardless of the presence of a watermark. So, I have changed the recognized reply and forward prefixes to treat forwards like replies and sorted out the forwards and replies by using a script.

The scenario 1 and 2 are working fine with the script but for the 3rd scenario, "Create Incident" is processed instead of my inbound email action. Please help me resolve the issue.

if((String(email.subject).indexOf('Fwd:') > -1) || (String(email.subject).indexOf('Fw:') > -1))

{

  if(String(email.body_text).indexOf('Ref:MSG') > -1)

  {

  // forward email with watermark

current.update();

}

}

  else if(String(email.body_text).indexOf('Ref:MSG') == -1)

  {

// forward email without watermark

current.insert();

  }  

}

else

{

  // reply email

current.update();

}

}

4 REPLIES 4

coryseering
ServiceNow Employee
ServiceNow Employee

Hi Karthik,



Does the "Create Incident" have a higher Order than your Inbound Action?


Do you set event.state="stop_processing"; in your Inbound Action to prevent any other actions from running after yours?



Also, remember the flow for how ServiceNow determines which type of Action to run for a given inbound email:


Inbound_email_action_type.png


Thanks Cory


New Developer_S
Giga Sage

@karthikdoure  Can you please share the complete code how you executed this functionality  ?

1. Reply email (Obviously has watermark)

2. Forward email with watermark

3. Forward email without watermark

TIA

GB14
Kilo Patron

@karthikdoure how did you achieve this inbound action? How did you catch the forwarded email, query, and update the current active incident?