function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vijaya Kumar RegantiVijaya Kumar Reganti 

How to remove the HTML tags that are displaying in the text

Hi All,

 

I have a code to send the email.Upon sending the email,I am creating an activity with that mail.

 

But when I am saving the body of the email into Description field of the Activity, all the HTML tags are appearing.

 

Like if there are multiple lines present in the body of the mail, then it displays multiple <br></br> tags for each line.

 

Please help me resolve this issue.

 

Thanks,

 

vijay

Best Answer chosen by Admin (Salesforce Developers) 
Vijaya Kumar RegantiVijaya Kumar Reganti

Hi Friends,

 

Finally I got my own solution for this.

 

I have done it using the following method to eleminate the HTML tags from the rich text area field.

 

replaceAll('<[/a-zAZ0-9]*>',' ');

 

replaceAll('&nbsp;',' ');

 

Thanks,

 

Vijay

All Answers

kevin lamkevin lam

Have you tried the String.stripHtmlTags() method?

Vijaya Kumar RegantiVijaya Kumar Reganti

Can u please explain how to use this in my case 

 

TT.Description = '<img src="'+SchoolPortalEmails.Header_Graphic_Link__c+'"/>\r\n<p>'+SchoolPortalEmails.Body_Of_Email__c+'<p>';

 


in the above case only I am getting the problem.

 

Thanks,

 

vijay

kevin lamkevin lam

TT.Description = TT.Description.stripHtmlTags();

Vijaya Kumar RegantiVijaya Kumar Reganti

Hi Friends,

 

Finally I got my own solution for this.

 

I have done it using the following method to eleminate the HTML tags from the rich text area field.

 

replaceAll('<[/a-zAZ0-9]*>',' ');

 

replaceAll('&nbsp;',' ');

 

Thanks,

 

Vijay

This was selected as the best answer
Aishwary Gupta 21Aishwary Gupta 21
I am directly passing the value on VF page like:

<td><p>{!Var.Field__c}</p></td>    


Expected Output : FieldValue
Actual Output : <p>FieldValue</p>

How to trim the HTML tags (i.e. <p></p>) from output ?
MUNEEB AHMED 2MUNEEB AHMED 2

Use this to remove HTML tags from rich text area field in JavaScript:
const strippedString = htmlString.replace(/(<([^>]+)>)/gi, "");
console.log(strippedString);