Field can not be filtered in SOQL query call

Here is my SOQL code for finding records to update but it is generating a compiler error like “field ‘Chatter_Monitor_Policy_Keyword__c’ can not be filtered in query call”. Why can’t I filter by this field?

string abc = obj[0].Chatter_Monitor_Policy_Keyword__c;
string s ='%'+ abc + '%'; 
List<Chatter_Monitor_Policy__c> records = [SELECT Id, Chatter_Monitor_Policy_Keyword__c from Chatter_Monitor_Policy__c where Chatter_Monitor_Policy_Keyword__c Like:s and CreatedById =: UserInfo.getUserId()];
  for(Integer i=0; i<records.size(); i++)
    records[0].Chatter_Monitor_Policy_Keyword__c = s;
    update records[0];


Textarea field types are filterable, but it needs to be done in the QueryResult

Quote from SOAP API page

Textarea Field Type

Textarea fields contain text that can be longer
than 4000 bytes. Unlike string fields, textarea fields cannot be
specified in the WHERE clause of a queryString of a query() call. To
filter records on this field, you must do so while processing records
in the QueryResult
. For fields with this restriction, its filterable
field in the Field type (described in the fields property of the
DescribeSObjectResult) is false.

So get the query results into a queryresult object, and filter over each of the returned objects.

Source : Link , Question Author : Kishan Trambadiya , Answer Author : Saariko

Leave a Comment