Remove external message via inbound action

Brian Lancaster
Tera Sage

We are using our own system to send emails. When a user replies back it go though our system and then gets forwarded to the ServiceNow email to be processed. As it goes thought our system an external message gets added to the beginning of the email. I would like to find a way to remove this so it does not show up in the comments when an incident / request is updated. The starting text and the end of the text does not seem to change but they sometime change what is in-between. Is there a way to use the start and end of the text to remove the message?

 

1 ACCEPTED SOLUTION

Viraj Hudlikar
Giga Sage

Hello @Brian Lancaster 

Just a thought if it helps you.


In your email system, modify your email processing to clean email body before forwarding to ServiceNow (Recommended) approach I feel, might your system expert can help on that part.

 

Alternative, when email is received in inbox table do processing over body content and remove unwanted stuff before insertion. Or something with inbound email action from script try to get content apply regex to remove content which is fixed as you saying.

Let me know if you find any solution would be glad to hear more on this usecase.

If my response has helped you hit helpful button.


Thanks & Regards
Viraj Hudlikar.

View solution in original post

3 REPLIES 3

Viraj Hudlikar
Giga Sage

Hello @Brian Lancaster 

Just a thought if it helps you.


In your email system, modify your email processing to clean email body before forwarding to ServiceNow (Recommended) approach I feel, might your system expert can help on that part.

 

Alternative, when email is received in inbox table do processing over body content and remove unwanted stuff before insertion. Or something with inbound email action from script try to get content apply regex to remove content which is fixed as you saying.

Let me know if you find any solution would be glad to hear more on this usecase.

If my response has helped you hit helpful button.


Thanks & Regards
Viraj Hudlikar.

@Viraj Hudlikar, They said they cannot change anything to remove it when it forwards to the ServiceNow mail server. I was able to come up with the following code to remove it but I don't want to have to do it in every inbound action. I tried to put this in a script include but it doesn't see to allow me to call it from a inbound action. Is this a limitation?

var emailBody = email.body_text.replaceAll("warring text.","");
	emailBody = emailBody.trim();

Brian Lancaster
Tera Sage

Got it working by calling a script include so that way I only have to call the script include on each inbound action that can process an email from an external sender.

Script Include:

var InboundActionFunctions = Class.create();
InboundActionFunctions.prototype = {
    initialize: function() {
    },
	warningText: function(bodytxt){
		var bodytext = bodytxt.replaceAll("First sentence.\n second sentence.\n",""); //You will need to figure out what your warrning message look like in text format.
		bodytext = bodytext.trim();
		return bodytext;
	},

    type: 'InboundActionFunctions'
};