+ Start a Discussion
vijendahr kvijendahr k 

unable to query on encrypted fields

Hello all,
 
 In my org contact email Field is ecnryped fields , but i need to query list of email address using soql, like

 list< contact> con= [select id, name , email from contact where email=:listofUniqueemail];
but i am unable to use this command,

 i tryed to use sosl query to get contacts related to email address

list<list<contacts>> conlist= [find :listofUniqueemail retrun all  contact (id, name , email ))];

issue in this query is listofUniqueemail  we cant use the set in soql query , its giving error unable to handle list.

can you please tel me how to fix this issue. your help is very needed to fix issue.
i tried https://www.codescience.com/blog/2017/salesforce-platform-encryption-the-good-the-bad-and-the-ugly-3-areas-to-review-closely link its not worked. please give me dirct solution

Thanks
Vijendhar






 
VIGNESH BALASUBRAMANIANVIGNESH BALASUBRAMANIAN
Hi vijendhar,

If you are not querying more records, you can query all the records and use if condition to check whatever you want, like below,
 
List<Contact> con= [SELECT Id, Name ,Email FROM Contact];
for(Contact cnt:con)
{
 if(listofUniqueemail.contains(cnt.Email)
  {
    //logic's
  }
}

Thanks.
Suraj Maharjan 3Suraj Maharjan 3
To query encrypted fields you must be able to view thoes fields first.
Create a permission set, with view encrypted fields permission, assign it to yourself and then run a query.
vijendahr kvijendahr k
Hello Vignesh,
 
i modified code according, above snippet i am getting "execution of BeforeInsert

caused by: System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times) 
" error.

this i was tried already.. this above snippet not able handle it.

Thanks 
Vijendhar