Filter SOQL query on Text Area Long Field in Apex
As a standard salesforce limitation, we cannot filter on the salesforce Text Area Long field. It will give us an error stating ‘Field cannot be filtered on a query call’.
SCENARIO : Suppose we have a scenario where we have to get a list of records that contains a specific test in a custom Text Area Long Field and checks if the same text is on the Site field.
SOLUTION :
We can hold the records to be filtered in a list and then iterate through this list manually to check if the long text area field contains specific text.
ADDITIONAL INFO— In SFDC reports you can filter on long text areas in reports with the limitation that only the first 255 characters are used as the value in the filter but same is not the case in the SOQL query.
How Can You Contribute?
- Connect with me on Linkedin/Twitter
- Endorse me on Linkedin for Salesforce
- Reach me out on LinkedIn, if my knowledge in salesforce can help you.
Posts in the previous series :
Salesforce Development — Learning Apex Programming, VisualForce, Lightning Components
First Step toward Learning Apex Programming
Day 2 in Apex — Writing apex codes
Working with sObjects, SOQL, and SOSL
Understanding Salesforce Triggers and working with them
Apex Test classes and methods
Understanding VisualForce Concepts
Controllers in VisualForce