Strip off email disclaimer on Inbound Email Action

Not applicable

I'll preface this by saying I'm still very much a beginner javascript developer, but does anyone have a script in their Inbound Email Action to remove a standard email disclaimer?

I figured it is a quite common request, particularly when the business users are emailing in incidents. Can the "Create Incident" incident detect the string "Legal disclaimer:" and ignore adding the rest of the email body into the additional comments field.

I'm unable to find the particular example I'm looking for on the wiki (useful scripts, inbound email action examples) or this forum. http://wiki.service-now.com/index.php?title=Inbound_Email_Action_Examples

Thanks guys.

4 REPLIES 4

Not applicable


brenb


Create Incident action


CapaJC
ServiceNow Employee
ServiceNow Employee

System Properties --> Email Properties, look for the following property:
" For reply emails, discard everything below this text if found in message body"


Not applicable

Thanks mate. Yeah I've been trying this property.

This config is for -reply- emails into the system though, not new emails for incidents being initiated by the users.


CapaJC
ServiceNow Employee
ServiceNow Employee

For new emails, you might have to do your own JavaScript string parsing in the Inbound Email Action. You'd need to make use of the indexOf(), either substr() or substring() (I always forget the difference and have to Google them every time I need them), and set current.comments to be a new string you make out of email.body_text instead of using the default current.comments line in the inbound email action.

Something like:
// idx will be the position of the text you're looking for
var idx = email.body_text.indexOf('your delimiting text here');
// s will be the substring from the beginning to the start of your text
var s = email.body_text.substring(0,idx);
current.comments = "received from: " + email.origemail + "\n\n" + s;

You'll need to tweak this, probably.