Translated HTML fields show HTML code in email notifications
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2012 12:21 PM
For some reason when I include a field that is a Translated HTML field into an email notification, the HTML code prints and it looks like a mess. How do I get the data from the field to format properly? Regular HTML fields work fine.
I first noticed this when working on our kb_submission form. I'm trying to get the text to be included in the approval email notification. I'm also trying to include that same text in a notification to the Service Desk for Knowledge Articles are updated.
Thanks,
Rosa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2012 12:54 PM
Try using a mail script to strip out all the html content.
In the Message field on your Notification record, you would typically put something like this:
Translated Field Contents = ${u_mycustomfield}
Instead, try something like this:
<mail_script>
var cleanString = current.u_mycustomfield.toString().replace(/(<([^>]+)>)/ig,"");
template.print("Translated Field Contents = " + cleanString + "\n");
</mail_script>
This will use a regular expression pattern (/(<([^>]+)>)/ig) to find html tags and clear them by replacing them with an empty string.
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2012 01:17 PM
Thanks for the reply.
I tried adding the mail script and it did remove all of the html tags but all of the formatting and line breaks are now missing and it looks like a jumbled mess. So I guess I need the html formatting but I don't want the code to show.
Does this make sense?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2012 01:33 PM
Can you attach a screenshot?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2012 01:51 PM
Would you mind posting the message body? Here are the steps to do so:
1. Open up the the Email Log (look for "Emails" under "System Logs")
2. Locate one of the e-mails that has the extra tags (one from before the mail_script part was added)
3. Open the email
4. Find the "Body" field and copy that text
5. Come back into this form and type
after the message body you pasted
<pre>
[code]<div><b>html message body</b></div>
It should look something like this [code][code]