function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to filter text area field?

Any guidance would be much appreciated.

I'm trying to extract records from Ideas, where a custom field is populated.

i.e. I'm wanting to do an equivalent of SQLs  WHERE Body like:+SearchText+''

The field is a  Text Area.


I've tried WHERE field='' and various other things, but Data Loader tells me the field can't be filtered on ...Am I just getting syntax wrong or can I really not filter on a text area field? That seems odd so guessing my syntax is duff.


I think long text area field cannot be filtered, not sure about text area. You can check this with isFilterable() function on Describe field.

Schema.DescribeFieldResult F = Account.AccountNumber.getDescribe();


If you really want to implement the filter function, you can try to use the formula field to copy the text area values, and filter on that. But this will have some limitation on the field length.


Actualy i am going to search from Ideas i.e. a standard object. In that i use find similar method also bt i think it has some limitations its not showing me more than 5 records...


 Id[] similarIds = Ideas.findSimilar(new Idea(title=searchText, Body=searchText));

than i use sts to get the ids using soql query but in that i cant search on body filed coz its a textarea.


  list<Idea> idealist = new list<Idea>();

  set<Id> similarIds = new Set<Id>();

     idealist =[Select id,title,body from Idea Where (title like :'%')+SearchText+'%')];

       for(Idea i : idealist){
            System.debug('similarIds-->'+ similarIds); 



now this is running but if i search like

idealist =[Select id,title,body from Idea Where (title like :'%'+SearchText+'%') AND (Body like :''+SearchText+'') ] ;

then it gives me error: complile error: body field cannot be filter in query call..


So can any body tell me how i will make modifications in this or any other idea to do this...

Any help will be appriciated..





You can filter the Text Area Field but not the Long Text Area Field.





i am filtring the text area field only but it shows me the error.



I gave filter condition for TextArea,it worked for me without any error.what is the error you are getting?




error: complile error: body field cannot be filter in query call..

when i query:
 idealist =[Select id,title,body from idea Where (title like :''+SearchText+) AND (body like :''+SearchText+'') ];




Body field in Ideas Object is RichTextArea ,you cannot filter this field.Check out the Access

of this field in eclipse.






If it resolves your problem,accept it as solution so that others benefit from this.





ok so wts the other option to do so?  i need to search on title as well as body aslo. so how can i do? 

Amar cAmar c

getting same issue   any suggestion.I have to use like query with Long Text Area with custom object.Is this possible any way?


There is an alternative to do what you ask, you got to query all records and save in a list.

Iterating this list and checking for the text area filter condition will be the way.