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
Athul Mathew PandavathuAthul Mathew Pandavathu 

We need to search leads based on SSN#...I got a response from a forum that SOQL on encrypted fields are not possible...is there way to make a search based on SSN#

Shri RajShri Raj
Yes, you can perform a search on encrypted fields like SSN# in Salesforce. However, you cannot directly perform a SOQL query on an encrypted field. To search based on SSN#, you can follow these steps:
Create a custom field on Lead object to store the unencrypted SSN# value.
Write a trigger to encrypt the custom SSN# field on Lead object after insert or update.
Perform the SOQL query on the custom SSN# field to search leads based on the SSN# value.
Note: Ensure that you follow the security best practices while handling sensitive information like SSN# and also consider the data privacy laws that may apply to your organization.
ATHUL MATHEW 18ATHUL MATHEW 18
this is actually a custom lead object...the ssn__c is encrypted..so u meant to say this 2nd field, which is encrypted through trigger, will be available for SOQL (WHERE SSN=xxxxxxxxx) query right ?
SubratSubrat (Salesforce Developers) 
Hello Athul ,

Requesting you to go thriough this discussion also once for your ask.
--> https://salesforce.stackexchange.com/questions/291470/encryption-querying-do-i-need-shield

Hope it helps !
Thank you.