+ Start a Discussion
Briana L.Briana L. 

SOSL for Encrypted Field returns no results

I am trying to write a SOSL query to find a match on a custom Social Security Number Field. According to the documentation, SOSL should be able to return results for encrypted fields, but the results returned are blank.

My user has "View Encrypted Data" permission.
We are managing a package, but the code includes the namespace.

This SOSL returns 0 rows, and an empty list, even though I KNOW that there are records with '1111' in the social security number custom field because I created them for testing.
List<List<sObject>> results = [FIND '1111' IN 
                               ALL Fields RETURNING 
                               aescsep__SCSEP_Participant__c(id, name, aescsep__social_security_number__c)];
I know that the syntax of the SOSL is correct because if a replace the '1111' keyword with something like 'test' I am able to return records that have 'test' in non-encrypted fields.

Can someone please provide a solution that will return matching participants by encrypted SSN?
Raj VakatiRaj Vakati

For the record, text(Encrypted) is not the same as text, hence, not queryable with SOSL.
When Using Shield Platform Encryption, There are certain considerations when using SOSL and SOQL:

Briana L.Briana L.
Hi Raj,

Yes I understand that text(Encrypted) is not the same as text.
However, this resource: https://developer.salesforce.com/page/ISVPlatformEncryption#Key_limitations_and_their_workarounds indicates that you can use SOSL to query for encrypted fields, and I followed the example exactly but it is not working.
Raj VakatiRaj Vakati
It seems to be confusing for me also .. i tried same in my instance but no data is returned