March 11, 2013

Converting HTML e-mail to plain text inside CRM 2011

E-mail activities inside CRM 2011 support HTML content (email's body is stored inside the field "description") as shown in this figure:

If is necessary to remove the html formatting to display only plain text, the following code can be used:
function StripHTML(html) {
   return html.replace(/<[^>]*>?/g, "");
}

// example

var description = Xrm.Page.getAttribute("description").getValue();
var plaintext = StripHTML(description);
Xrm.Page.getAttribute("description").setValue(plaintext);

1 comment: