Removing signature statement in inbound emails.

Daniel Shock
Kilo Sage

We have a standard signature that I would like to have removed to improved legibility in incidents.   Reading this thread: https://community.servicenow.com/thread/180541   I see that it looks like we can do it in an inbound action.   Is that right? The same inbound action that creates the incident?   I created a system property...I'm just not sure how to modify our existing inbound action to strip it out...

Here is our current inbound action script:

// Note: current.opened_by is already set to the first UserID that matches the From: email address

current.caller_id = gs.getUserID();

current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;

current.short_description = email.subject;

current.category = "inquiry";

current.incident_state = IncidentState.NEW;

current.notify = 2;

current.contact_type = "email";

if (email.body.assign != undefined)

    current.assigned_to = email.body.assign;

if (email.importance != undefined) {

    if (email.importance.toLowerCase() == "high")

          current.priority = 1;

}

if (email.body.priority != undefined)

    current.priority = email.body.priority;

current.insert();

The system property I created is named:

becks.confidentiality.signature

I am really new at this ...trying to wrap my head around it...

4 REPLIES 4

Geoffrey2
ServiceNow Employee
ServiceNow Employee

I think the main challenge you will have with this is trying to identify the signature given that the body of an email if often changed and reformatted quite drastically by different systems.   So changes in white-space are probably going to be an issue if you have a long signature.



Option 1 removes the signature if it finds an exact match.   Option 2 will probably work better.



// Note: current.opened_by is already set to the first UserID that matches the From: email address



//Identify any Footer/Auto Signature standard text to be stripped from email.


var signature = gs.getProperty('becks.confidentiality.signature');


var body = String(email.body_text);



// Option 1 - Hope for an exact match


body = body.replace(signature, '');



// Option 2 - Trim everything after the signature


var startOfSignature = signature.substring(0, 40); // first few characters of the signature


var indexOfSignature = body.indexOf(startOfSignature);


if (indexOfSignature > -1)


        body = body.substring(0, indexOfSignature); // trim everything from the signature



current.caller_id = gs.getUserID();


current.comments = "received from: " + email.origemail + "\n\n" + body; // Update body here


current.short_description = email.subject;



current.category = "inquiry";


current.incident_state = IncidentState.NEW;


current.notify = 2;


current.contact_type = "email";



if (email.body.assign != undefined)


        current.assigned_to = email.body.assign;



if (email.importance != undefined) {


        if (email.importance.toLowerCase() == "high")


                  current.priority = 1;


}



if (email.body.priority != undefined)


        current.priority = email.body.priority;



current.insert();


may thanks this really helped me clear all for a mailto reply templated email, i included the watermark in the mailto email and used this for the property to keep the inbound action to set the work_note nice and cleanly.  

 

For anyone else this is what i had:

find_real_file.png.  

find_real_file.png

 

find_real_file.png

 

which gave me this:

find_real_file.png

 

 

 

darius_koohmare
ServiceNow Employee
ServiceNow Employee

Although this is a viable method, if the format of your corporate signature is standardized....


Here's another common approach:


https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/administer/reference-pages/refer...



There's a property for reply seperators, and the system automatically discards text after the seperator. It's commonly used for stripping out signatures as well.


glide.pop3.reply_separatorsDiscard everything below this text if found in a reply body (comma separated, case sensitive)Specifies the comma-separated list of separators that cause the instance to disregard everything below the text string in the message body. This list is case sensitive.
  • Type: string
  • Default value: \n\n-----Original Message-----,\n\n _____ \n\nFrom:

Nice one. Yeah, I like that solution better.