2

I am working on use case, where i need to search a keyword on a custom Object containing three Rich Text Fields. I am using the string method containsIgnoreCase(). But even if the field contains the keyword, i get false in return when i do ( Rich_Text__c.containsIgnoreCase(keyword) ). Am i doing something wrong here, or is there a better way to do this ?

Note :

  1. The Rich_Text__c records currently contain only texts with some HTML markups.
  2. I have done a SOQL Query to search on the Custom Object
2
  • 1
    I'm not able to replicate. If I query a record to variable obj with a rich text field Rich__c whose contents are <p><u>This is underlined.</u></p><p class="ql-indent-1">This is a keyword: <b>zebra</b>.</p> then obj.Rich__c.containsIgnoreCase('zebra') returns TRUE. Can you post come sample code to illustrate your exact problem? It's also not clear how SOSL fits into your scenario/problem. May 17, 2019 at 18:13
  • Sorry it was SOQL, updated my question to reflect it. May 20, 2019 at 10:03

1 Answer 1

0

Rich Text Fields are a tough nut to crack because of the different types of text/data that they can contain.

My suggestion is first convert this to a text field & use the string methods whatever you need

String Inputfield = yourObject.rich_text_field__c;

Inputfield = Inputfield.replaceAll('<[/a-zAZ0-9]*>','');
3
  • 3
    stripHtmlTags would be more effective, actually.
    – sfdcfox
    May 17, 2019 at 14:58
  • yay that's a good idea I think so
    – Pavan tej
    May 17, 2019 at 15:23
  • Yes, stripping the HTML , worked for me . Thanks !! May 20, 2019 at 10:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .