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
Mario Conteddu 1Mario Conteddu 1 

Filtering null long text area fields in SOQL

Would it be possibile to filter null long text area fields in SOQL?

I need to run process where if a number of text area fields in contact are null then do something.

Thanks in advance!

 

Best Answer chosen by Mario Conteddu 1
Sukanya BanekarSukanya Banekar
Hi Mario,

Yes, Sandhya is right. You can not use text area field in filter critea but you can check null after query for eg.
integer cnt=1;
for(Account obj:[SELECT Description from Account]){
    if(obj.Description == NULL){
        system.debug('cnt---'+cnt);
        cnt++;
    }	
}

I hope this helps you.

Thanks,
Sukanya

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi Mario Conteddu,

You can not use text area fields in SOQL and SOSL filter criteria's.

Please refer below links which have some proposed solution that can help you.

https://developer.salesforce.com/forums/?id=906F00000008zxSIAQ
 
http://lc169.blogspot.sg/2013/06/long-text-field-limitations.html

http://sfdcmaniac.blogspot.sg/2014/03/you-cannt-include-textarea-fields-in.html

Hope this helps you!

If this helps you , please mark it as solved so that it will be available for others as a proper solution.

Thanks and Regards
Sandhya
Sukanya BanekarSukanya Banekar
Hi Mario,

Yes, Sandhya is right. You can not use text area field in filter critea but you can check null after query for eg.
integer cnt=1;
for(Account obj:[SELECT Description from Account]){
    if(obj.Description == NULL){
        system.debug('cnt---'+cnt);
        cnt++;
    }	
}

I hope this helps you.

Thanks,
Sukanya
This was selected as the best answer
EldonEldon
HI Mario,

you can achieve this by using a formula field in your custom object,
Try the below formula to calculate the number of fields that are not blank:(give your text area fields hereas field1 field2 field3...)
 
If(ISBLANK(Field1__c),0,1)+
If(ISBLANK(Field2__c),0,1)+
If(ISBLANK(Field3__c),0,1)+
.........

You will get the number of null fields in that field and can use it in your logic

Let me know if you have any issues.

Regards
Ajay mishraAjay mishra
Hi Mario,

If the operation whichi you want to perform are not much complex.

You can use Process Builder to do the same.

Thanks
Ajay Mishra
Email: mishraajay.m1@gmail.com
Mario Conteddu 1Mario Conteddu 1
@Ajay, unfortunatelly the operation is quite complex. I've tried with PB already and it works but PB processing is not quick enough and when I modify records through data loader, it causes issues.