
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 04:12 PM
Hi all,
I have an email mailbox forwarding to ServiceNow and in turn an inbound email action to create RITM's using the shopping cart. All is working well, however for some of these emails they are HTML. My inbound action is simply putting the body of the email into the description field, but for the html emails it is obviously bringing along all of the html, tags, formatting and all.
I've tried both the email.body_html and email.body_text to no avail. I've read a bit since about parsing, but before I go down that road I'm hoping their is an easier solution based on how this particular team deal with RITM's.
They don't view them via a traditional list of RITM's. THe team work purely off cards in a Visual Task Board.
I am hoping that somehow we can deliver this html as some kind of image attachment instead that shows in the VTB card. Left field I know, but hoping I can simplify it , rather than go down the parsing route (this will be difficult as the type of html coming in is different every time).
Thanks for your help in advance!
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 09:43 PM
I thought I'd post here a solution that ended up fixing this by stripping all the HTML in the email incoming. Hopefully this helps others 🙂
Use the below to set a htmlcode variable and then use it in replacement of email.body_html . I got this from - https://community.servicenow.com/community?id=community_article&sys_id=8dcdc538db50ccd0d82ffb2439961...
var htmlcode= email.body_html;
htmlcode = htmlcode.replace(/<style([\s\S]*?)<\/style>/gi, '');
htmlcode = htmlcode.replace(/<script>/gi, '');
htmlcode = htmlcode.replace(/<\/div>/ig, '\n');
htmlcode = htmlcode.replace(/<\/li>/ig, '\n');
htmlcode = htmlcode.replace(/<li>/ig, ' * ');
htmlcode = htmlcode.replace(/<\/ul>/ig, '\n');
htmlcode = htmlcode.replace(/<\/p>/ig, '\n');
htmlcode = htmlcode.replace(/<br\s*[\/]?>/gi, "\n");
htmlcode = htmlcode.replace(/<[^>]+>/ig, '');
htmlcode=htmlcode.replace(' ','');
htmlcode=htmlcode.replace(/\r/g, "");
htmlcode=htmlcode.replace(/^\s*$(?:\r\n?|\n)/gm, '');
htmlcode=htmlcode.replace(/(.*) (.*)|IMPORTANT INFORMATION.*|Copyright ©.*/gm,'');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 05:46 PM
Hi, does the description field render HTML?
If it does you may still need to encapsulate your message "[code]" "[/code]"so that it is displayed correctly.
https://docs.servicenow.com/bundle/london-platform-administration/page/administer/field-administration/task/render-journal-field-entries-as-html.html
Also, not every company populates their full HTML content into (plain)body_text, so the detail might just not be in the plain text field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 09:05 PM
Thanks Tony,
the Description field in RITM doesn't render HTML as far as I know, and while you can configure it too, it will change the task tables description field for all Ticketing so not desirable. I could create a new field that renders html and move my email body into this, however then the team (only using Visual Task Boards) will not be able to see the desired info in the card at a glance (as the card popup only shows Description, Short description, attachments, work notes and comments). The team don't want to work of opening a traditional RITM, as they are a business team who are trying to basically use VTB's for requests.
I wonder if I do create a new HTML rendered field, put this information in it, choose to disable compact cards and show all information in my VTB, will this html render properly in the card. I'll give that a go.
If not, I wonder whether there is a way to get this html displaying as an attachment somehow, as VTB's handle attachments without issue rendering??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2019 09:43 PM
I thought I'd post here a solution that ended up fixing this by stripping all the HTML in the email incoming. Hopefully this helps others 🙂
Use the below to set a htmlcode variable and then use it in replacement of email.body_html . I got this from - https://community.servicenow.com/community?id=community_article&sys_id=8dcdc538db50ccd0d82ffb2439961...
var htmlcode= email.body_html;
htmlcode = htmlcode.replace(/<style([\s\S]*?)<\/style>/gi, '');
htmlcode = htmlcode.replace(/<script>/gi, '');
htmlcode = htmlcode.replace(/<\/div>/ig, '\n');
htmlcode = htmlcode.replace(/<\/li>/ig, '\n');
htmlcode = htmlcode.replace(/<li>/ig, ' * ');
htmlcode = htmlcode.replace(/<\/ul>/ig, '\n');
htmlcode = htmlcode.replace(/<\/p>/ig, '\n');
htmlcode = htmlcode.replace(/<br\s*[\/]?>/gi, "\n");
htmlcode = htmlcode.replace(/<[^>]+>/ig, '');
htmlcode=htmlcode.replace(' ','');
htmlcode=htmlcode.replace(/\r/g, "");
htmlcode=htmlcode.replace(/^\s*$(?:\r\n?|\n)/gm, '');
htmlcode=htmlcode.replace(/(.*) (.*)|IMPORTANT INFORMATION.*|Copyright ©.*/gm,'');