+ Start a Discussion
Michael MMichael M 

Soql WHERE long text area != null

Hello, i need to find records where a long text area field is not null. However i am getting an error that you cannot filter soql queries with long text areas. Is there any way to workaround this?
Best Answer chosen by Michael M
AbhishekAbhishek (Salesforce Developers) 
https://salesforce.stackexchange.com/questions/21298/filtering-by-long-text-area-field-in-soql

This will answer your query.

And an Idea is already raised for "Allow filtering on long text areas in SOQL"

https://trailblazer.salesforce.com/ideaView?id=08730000000ksTKAAY#:~:text=In%20SFDC%20reports%20you%20can,filter%20on%20long%20text%20areas.

Please vote it.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.

All Answers

AbhishekAbhishek (Salesforce Developers) 
https://salesforce.stackexchange.com/questions/21298/filtering-by-long-text-area-field-in-soql

This will answer your query.

And an Idea is already raised for "Allow filtering on long text areas in SOQL"

https://trailblazer.salesforce.com/ideaView?id=08730000000ksTKAAY#:~:text=In%20SFDC%20reports%20you%20can,filter%20on%20long%20text%20areas.

Please vote it.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.
This was selected as the best answer
Michael MMichael M
Awesome- thank you
Sachin HoodaSachin Hooda
If you're in Apex Context. Since you can't add a filter to Textarea field in SOQL, instead, query record without using any filter, iterate with a filter & store them in a new list like,
List<Account> accList = [....];
List<Account> filteredList = new List<Account>();
for(Account acc : accList){
   if(String.IsNotBlank(acc.myTextArea__c)){ //add your filter here..
    filteredList.add(acc);
    }
}
Michael MMichael M
Excellent- thank you