Filtering by Long Text Area field in SOQL
You can not use text area fields in SOQL and SOSL filter criterias.
Try this approach:
List<Project__c> projects = new List<Project__c>();
for(Project__c proj : [SELECT Name, Status__c, Description__c FROM Project__c WHERE Name LIKE '%' + String.escapeSingleQuotes(name) +'%' + OR Status__c = String.escapeSingleQuotes(status)]) {
if(proj.Description__c.contains('filter string')) {
projects.add(proj);
}
}
There is an Idea to Allow filtering on Long Text Area, so you can't. In a pinch you could iterate over your results in a for loop and use String methods to filter out/in the desired results. Of course, that may not be reasonable depending on the number of records and whether or not what you are doing is needed in real time.
I just discovered a work around for this here. Create a Formula field that uses the LEFT formula and filter on that. You cannot filter on the ENTIRE long text but you can filter on part of it:
Legal_Street__c is a long text area. I created a formula field called StreetConc__c:
LEFT(Legal_Street__c, 40)
I then created a dummy record and put the text 'testingthis' in the Legal_Street__c field. From here I filtered on this formula field.
System.debug('answer = ' + [SELECT Name FROM Account WHERE StreetConc__c LIKE 'testing%']);
You should be able to apply this to both SOQL and SQL.