Change in Inbound Email Action Handles Email body in Description field

Debby Shea Ande
Tera Expert

We have an inbound mail action that is received from a specific sender email address. The inbound mail action creates a record, with basic contents placed in various fields. Specifically, the body of the email is placed in the Description field of the record.

The body of the email is mostly made up of an html table with two columns (think name: value pairs). The inbound email action treated each row in the table as a line in the description field, which was acceptable for our needs.

Until a few days ago, when the breaks stopped appearing. Now the body of the email is one long line of name/value pairs, and a user has to manually add line breaks to the description field.

I've evaluated the HTML in the body of emails sent before and after this occurred, and nothing appears to have changed there. Also, there is nothing on our org's change calendar that would point to how email is processed.

Any thoughts on what might have occurred recently?

I've attached screenshots of the inbound actions, and the formatting changes.

9 REPLIES 9

Hi Sheldon,

The code samples from before and after the issue started are identical in contents. When I copy and paste into Notepad++, the only difference is that the formed HTML in the body of the email is in one long line, whereas previously there were line breaks.

This leads me to believe that I will need to take another approach to solving the issue.

Thanks for your time!

That's interesting. Are you looking at the body of the emails on the email [sys_email] table? Where are the emails coming from? The class name suggests it might be some other system using a TinyMCE rich-text editor, in which case it might be that the TinyMCE configuration has changed.

 

If you're unable to get to the bottom of it, as a workaround, you can process the HTML before dropping it into the description field. That might look something like this:

var htmlContent = email.body_html; // Assume this is the HTML content
if (htmlContent) {
    // Use a regular expression to extract the table with id "emailFieldsTable"
    var tableMatch = htmlContent.match(/<table[^>]*id=["']emailFieldsTable["'][^>]*>[\s\S]*?<\/table>/i);

    if (tableMatch) {
        var tableContent = tableMatch[0]; // Get the matched table HTML

        // Replace closing table row tags with a line break
        tableContent = tableContent.replace(/<\/tr>/gi, '\n');

        // Strip out the remaining HTML tags
        var plainText = tableContent.replace(/<\/?[^>]+(>|$)/g, "");

        // Now you can set this plainText into the description field
        current.description = plainText;
    } else {
        // Do something
    }
} else {
    // Do something
}

Sheldon  Swift
ServiceNow Employee
ServiceNow Employee

Hi @Debby Shea Ande - Have you seen KB0791099?

This article points to the issue being caused by a conflict between how the inbound action handles the body of the email, and the Description field's field type (string, or HTML).

Unfortunately for me, neither of these have changed. They are aligned to be a string value. 

I just find it interesting that the inbound actions are treating the text differently with no changes to the email message formatting, to the description field, or to the inbound action itself.

Debby Shea Ande
Tera Expert

Thanks, I will try the solutions posted there. Appreciate you pointing me in the right direction.