Are you considering migrating from Salesforce Classic to Lightning Web Components (LWC)? It's a wise decision, as LWC offers improved performance, flexibility, and a modern user interface. However, migrating from Classic to LWC is not a trivial task and requires careful planning and execution. In this blog, we'll explore the key things to do and the essential tools to check when undertaking this migration.
Here I am going to show you, How to insert formatted data (table, colorful text etc) in rich text area field salesforce. We can directly use updated rich text area in our email templates without doing any extra code for email template.
Here is sample code.
Below code is for table:-
string table ='<p><span style=\"color: #2e6c80;\"><strong>Table Heading</strong></span>
</p>\r\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"font-size:12px;\">\r\n<tbody>';
table+=createColumn('table column ame 1','Table column Value 1');
table+=createColumn('Your column Name 2','table column value 2');
public static string createColumn(string column,string value){
return '<tr>\r\n<td>'+column+'</td>\r\n<td tabindex=\"0\">\r\n<div>'+value+'</div>\r\n</td>\r\n</tr>';
}
Here is sample code.
//Heading for rich text area content.
string body='<h3 style=\"color: #2e6c80;\">your heading :</h3>\n
<ol style=\"list-style: none; font-size: 12px; line-height: 32px; \">\n';
body += '<li style=\"clear: both;\"><b>'+Your Label Name+' : </b> '+
yourValue.replaceAll(';',' , ') +'</li>';
body +='</ol>';
yourRichTextAreaField=body;
Below code is for table:-
string table ='<p><span style=\"color: #2e6c80;\"><strong>Table Heading</strong></span>
</p>\r\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"font-size:12px;\">\r\n<tbody>';
table+=createColumn('table column ame 1','Table column Value 1');
table+=createColumn('Your column Name 2','table column value 2');
table+='</tbody>\r\n</table>';
public static string createColumn(string column,string value){
return '<tr>\r\n<td>'+column+'</td>\r\n<td tabindex=\"0\">\r\n<div>'+value+'</div>\r\n</td>\r\n</tr>';
}