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
sasmitasasmita 

Long Text Area text field can not be filtered in Query call

Hi,

Can any one help me in resolving issue with custom field with long text Area while using in where clause?
Query: Select ID, Name, Customer_Comments__c from Contact where 
Customer_Comments__c !=  null
Customer_Comments__c  is a type of Long Text Area- of length 30,000.

I wanted to use this field in SOQL query. But salesforce throws error while using this field in the filtered critieria in where clause.

Thanks,
Sasmita

 
Akshay_DhimanAkshay_Dhiman
Hi Sasmita,

The WHERE Clause doesn't work for the Long text Area, So to filter the records on the basis of Long Text Area please follow the below solution: 
List<Contact> contList = new List<Contact>();
List<Contact> newContList = new List<Contact>();    
contList=[SELECT ID,NAME,Customer_Comments__c FROM CONTACT Limit 100];
    if(contList.size()>0){
        for(Contact c: contList){
            if(c.Customer_Comments__c != null){
               newContList.add(c); 
            }
        }  
      }
    System.debug('-->Contact '+newContList);
Hope it will help you.
Regards
Akshay