I tried to run this query and got the error as 'name' can not be filtered in a query call. The query is [select id,name from contact where name like '%test%'] . The result is varying from org to org. I tried in my developer edition and it is working fine. when I try this is in my project sandbox and I got the mentioned error.

  • Is Name field encrypted in your project sandbox. Like are you using Salesforce Shield implementation? Mar 24, 2022 at 6:43
  • how do I know that field is encrypted. because when I use soql as plain like [select id,name from contact where firstname != null] . it is working totally fine. but I cannot use the like operator
    – prasanth
    Mar 24, 2022 at 6:45

2 Answers 2


As mentioned in my comment the encryption fields cannot be used in the filter criteria . You cannot use those field in Aggregate functions such as MAX(), MIN(), and COUNT_DISTINCT(),WHERE clause,GROUP BY clause,ORDER BY clause as well.

You may have to remove the encryption to use them in the above scenarios. Please find the below article from Salesforce which explains the same .

  • is there any other way other than removing the encryption?
    – prasanth
    Mar 24, 2022 at 8:02
  • 1
    There was a tip in the above article saying to Consider whether you can replace a WHERE clause in a SOQL query with a FIND query in SOSL. Mar 24, 2022 at 8:11

I came to know that the field is encrypted and I removed the encryption for contact name field and the query is working now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .