Filter SOQL query on Text Area Long Field in Apex

Prakher Chaturvedi
2 min readAug 8, 2021

--

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.

Here TextAreaLong is a custom field with Long text area type
Error Because TextAreaLong cannot be used in a where clause

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.

Resolution through iterating on the list and checking if it 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.

--

--

Prakher Chaturvedi

Looking for remote opportunities | Salesforce Developer | Lightning Web Components | APEX | 5x Certified | Trailhead Ranger | Content Creator (Medium)