Need help formatting comments field in email notification

purple123
Kilo Explorer

I want my email notification to customers to be easy to read just like first example.   Currently in my environment, the email includes the email threads which makes it hard to read.   How can I get rid of the thread part (Please see the emails in blue where I strike through the email parts)?   Please advise.   Thanks.   Diane

 

Example when I open a ticket with ServiceNow Support (hi.service-now.com):

1. I reports an incident.   Types in short description and steps to reproduce.

2. I get an email saying an incident is opened on my behalf.

Reading email in my Outlook, I see Email 1:

 

INC#: short description

----------------------------------------------------------------------------

my reproducible steps that I wrote (1, 2, 3.)             notes

 

3. Support representative writes back saying "thank you. I'll look into it, etc."

Email 2:

 

INC#: short description

----------------------------------------------------------------------------

thank you. I'll look into it, etc.                                                 notes

----------------------------------------------------------------------------

my reproducible steps that I wrote (1, 2, 3.)         notes

 

4.   I responded to email, "By the way, it's happening in PROD too."

Email 3:

 

INC#: short description

----------------------------------------------------------------------------

By the way, it's happening in PROD too               notes

----------------------------------------------------------------------------

thank you. I'll look into it, etc.                                             notes

----------------------------------------------------------------------------

my reproducible steps that I wrote (1, 2, 3.)     notes

 

 

Example what my 3 email notifications look like In my environment:

Email 1:

INC#: short description

----------------------------------------------------------------------------

my reproducible steps that I wrote (1, 2, 3.)             notes

 

 

Email 2:

INC#: short description

----------------------------------------------------------------------------

thank you. I'll look into it, etc.                                             notes

 

From: IT Service Desk

Sent: blah

My reproducible steps that I wrote (1,2,3)

----------------------------------------------------------------------------

my reproducible steps that I wrote (1, 2, 3.)         notes

 

 

Email 3:

INC#: short description

----------------------------------------------------------------------------

By the way, it's happening in PROD too               notes

 

From: IT Service Desk

Sent: blah

thank you. I'll look into it, etc.          

 

From: IT Service Desk

Sent: blah

My reproducible steps that I wrote (1,2,3)

----------------------------------------------------------------------------

thank you. I'll look into it, etc.                                             notes


From: IT Service Desk

Sent: blah

My reproducible steps that I wrote (1,2,3)

----------------------------------------------------------------------------

my reproducible steps that I wrote (1, 2, 3.)     notes

1 ACCEPTED SOLUTION

cbailey1
Mega Contributor

I'd agree with this and Terri's response above.   It seems like if the e-mail header information is written to the comments on your incident ticket, you definitely have something going on in the Inbound E-mail Actions for the incident table.   Out of the box there is typically a "Create Incident" and an "Update Incident" action. (Check under "System Policy" -> "Email" -> "Inbound Actions" if you're not familiar.)   You may want to post the contents of one or both of those rules if you're still having trouble, as I'm sure someone here will be able to give you a fix pretty quickly.



If you haven't customized those rules yet, chances are that you'll find a line or two about:



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




Change that line to something more like:



current.comments = "email.body_text"




The "received from: " + email.origemail" is very likely the part giving you the lines you don't want.   In case you want to customize the action in some other way once you start looking at it, check the Wiki article on Inbound Email Actions: Inbound Email Actions - ServiceNow Wiki




As always, take this with a grain of salt and test this first before just implementing in production.


View solution in original post

7 REPLIES 7

TJW2
Mega Guru

It looks like these comments are coming from the email body when an 'Inbound Email action' runs.   In your 'Inbound Email Action' ; you can parse out the information you don't want to store before putting in the comments fields   (From:, Sent:....)


mduluk
Giga Expert

So it sounds like what you want to do is cut out the rest of the reply that is the old message.   On the inbound email action that updates the ticket, what if you did a split on the body of the message.   Something like this



var str1 = email.body_text;


var str = str1.split("From: IT Service Desk", 1);


  current.work_notes = str[0];



That would keep the journal history in the ticket clean too.


cbailey1
Mega Contributor

I'd agree with this and Terri's response above.   It seems like if the e-mail header information is written to the comments on your incident ticket, you definitely have something going on in the Inbound E-mail Actions for the incident table.   Out of the box there is typically a "Create Incident" and an "Update Incident" action. (Check under "System Policy" -> "Email" -> "Inbound Actions" if you're not familiar.)   You may want to post the contents of one or both of those rules if you're still having trouble, as I'm sure someone here will be able to give you a fix pretty quickly.



If you haven't customized those rules yet, chances are that you'll find a line or two about:



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




Change that line to something more like:



current.comments = "email.body_text"




The "received from: " + email.origemail" is very likely the part giving you the lines you don't want.   In case you want to customize the action in some other way once you start looking at it, check the Wiki article on Inbound Email Actions: Inbound Email Actions - ServiceNow Wiki




As always, take this with a grain of salt and test this first before just implementing in production.