14

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()];
if(records.size()!=null)
{
  for(Integer i=0; i<records.size(); i++)
  {
    records[0].Chatter_Monitor_Policy_Keyword__c = s;
    update records[0];
  }
}
11

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.

9

As indicated in the attached screenshot, check the "filterable" acces property of field in schema browser (Force.com IDE etc). This property indicates whether the field is filterable (true) or not (false). If true, then this field can be specified in the WHERE clause of a query string in a query() call. More details here : http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_describesobjects_describesobjectresult.htm

Check the "filterable" acces property of field in schema browser

  • Thanks. This was blocking me. You can also view the Schema in the Force Explorer AIR app if you don't want to use the Force.com IDE. – Joshua Dance Apr 17 '14 at 21:45
5

If Chatter_Monitor_Policy_Keyword__c is a text area then you can't filter by it, though if it truly is a keyword (or short list of keywords) then it should just be a text field which you will be able to filter by.

Can you confirm what type of field you are using? If it is a text area then I'd suggest changing it to a text field if possible.

If you absolutely can't change the field type, then you're probably limited to selecting all of the records and performing the search in code — to do this you'll likely need to leverage a batch apex class to process the data volumes involved.

  • yes Chatter_Monitor_Policy_Keyword__c is text area – Kishan Trambadiya Sep 11 '12 at 5:07
  • That's your answer then — unfortunately you can't filter by text area fields in SOQL! – Matt Lacey Sep 11 '12 at 5:11
  • Then what is the exactly solution for that??? – Kishan Trambadiya Sep 11 '12 at 5:12
  • 2
    @KishanTrambadiya You need to make it something other than a text area! – Matt Lacey Sep 11 '12 at 5:36
  • 1
    @KishanTrambadiya - well you can't filter on it then – metadaddy Sep 11 '12 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.