Inbound email not being converted to plain text in description for HR case for some emails

Arka Banerjee
Kilo Guru

Hi Team,

 

ArkaBanerjee_0-1749126007978.png

As you can see in the above screenshot, the description of this forward email which creates a  new HR case in SNOW has <p> tags, which means it was not converted to plain text as expected. This is happening in rare scenarios. Could someone please help with identifying what might be causing this.

 

@Ankur Bawiskar  

10 REPLIES 10

SANDEEP DUTTA
Tera Patron
Tera Patron

Hi @Arka Banerjee ,

Please follow these links :

HTML Tags are included in email body - Support and Troubleshooting

Solved: HTML Tags Description field - ServiceNow Community

 

Thanks,
Sandeep Dutta

Please mark the answer correct & Helpful, if i could help you.

Ankur Bawiskar
Tera Patron
Tera Patron

@Arka Banerjee 

you can identify the inbound email action and in the script strip the tags

check this link

Handling inbound emails with HTML in RITM Description field 

something like this in inbound email action script

function stripHTML(html) {
    return html.replace(/<[^>]+>/g, '').replace(/&nbsp;/g, ' ').replace(/&amp;/g, '&');
}

// Usage
var body = email.body_text || stripHTML(email.body_html) || '';

current.description = body;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks Ankur,

 

Please note that this has happened for a very miniscule no of HR cases. PFB the snippet of code which sets the description in our inbound action:

 

var bodyText = email.body_text;
if (!bodyText) {
    bodyText = email.body_html;
}
 
current.description = bodyText;
 
Could you please let me know if you identify anything with this code that might cause it to be set with the tags for a few HR cases and the necessary modification that I would need to make.
 
Thanks!

@Arka Banerjee 

seems it's entering the IF for few of those cases and hence picking the HTML

better to strip the tags when it enters IF

var bodyText = email.body_text;
if (!bodyText) {
    bodyText = email.body_html;
    bodyText = bodyText.replace(/<[^>]+>/g, '').replace(/&nbsp;/g, ' ').replace(/&amp;/g, '&');
}

current.description = bodyText;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader