+ Start a Discussion

Can't query Rich Text


Trying to filter on a rich text field yields the following error:




formation__Form_Field__c where formation__Info__c != ''
ERROR at Row:1:Column:584
field 'formation__Info__c' can not be filtered in query call






As specified in the API docs, you can't have a long area text field (including rich text area) in a SOQL Where clause.


This makes me very sad.


I find that it is not just in the where clause, but querying rich text fields seems to be broken across the board.  I have submitted this to Salesforce support for further evaluation, as this worked as recently as last month.

Joe ZaloomJoe Zaloom

Hi, have you gottan a reply from Salesforce by any chance? I find that I can't refer to a custom rich text field anywhere or I get an  INVALID_FIELD error.




what api version are you using in your script?  I switched to 19 and that fixed the issue.


You can query on rich text w/ api v. 19?


Yes.  You also need to make sure that you're using the most recent verions of Force.com in your ide.


can we use the rich text Area in email template?

Imran MohammedImran Mohammed

Yes, we can use Rich text fields in the email template.



Thanks Imran...


Be careful that you don't try to pull it into a plain-text email though.


How did u achieve that please explain.?


I have this scenario where i want to search in a Rich Text field Say "Search_Rich__c". How do i write the search SOQL string using the api V19.0? that u are talking about


have you tried something like



sObject[] myObject = [select FieldList from sObject where Search_Rich__c like '%search term here%'];




This is my VF page

<apex:page controller="SOQLController" >
  <apex:pageBlock title="Retrived Ids">
      <apex:dataList value="{!queryResult}" var="r">
             <apex:outputText value ="{!r.Id}" /> 


And this is the controller

public class SOQLController {

  public List<sObject> queryResult { get{return queryResult;}set{ queryResult = value ;}}
    public PageReference query(){
        // create the query string
        String qryString = [SELECT Id FROM Bill_Staments__c WHERE Rich__c like '%first bill%'];

        // execute the query
        queryResult = Database.query(qryString) ;
       return null;



And i get the following error

Error: Compile Error: field 'Rich__c' can not be filtered in query call at line 12 column 28



I got the same problem for TextArea field too. "field 'TextArea__c' can not be filtered in query call'.

I used SOSL query to filter this.

You can query Long Text Area fields and Rich Text area fields in SOQL, but you can't  filter by them.

See here for more (Salesforce.StackExchange is pretty awesome)!  http://salesforce.stackexchange.com/questions/21298/filtering-by-long-text-area-field-in-soql