We are querying Salesforce using SOQL, if the encryption is enabled for the field that is used in query, we are getting the following error.
Operator like is not supported on an encrypted field
Is there any workaround for this issue?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityWe are querying Salesforce using SOQL, if the encryption is enabled for the field that is used in query, we are getting the following error.
Operator like is not supported on an encrypted field
Is there any workaround for this issue?
Operator LIKE is not supported on an encrypted field so you cannot use it, there is not much you can do about that.
What deterministic encryption allows you to do, as opposed to probabilistic, is to use the operator =
in a SOQL query since deterministic encryption guarantees that a certain sequence of bits will always be encrypted to the same sequence of bits.
If I were you I would try to change the query that uses the LIKE
operator to use =
operator. This will also speed up your query significantly.
If you use Deterministic Encryption then LIKE
operator is supported.
Deterministic encryption supports WHERE clauses in SOQL queries and is compatible with unique and external ID fields and custom indexes.
For example, you might run a SOQL query in custom Apex code against the Contact object, where LastName = 'Smith'. If the LastName field is encrypted with probabilistic encryption, you can’t run the query. Deterministic encryption addresses this problem.