Volunteers-for-Salesforce
Volunteers-for-Salesforce copied to clipboard
Clicking the "Find Volunteers" tab in an org using deterministic encryption returns 'Name' can not be sorted in a query call
If a customer enables Deterministic Encryption on the Contact Name field, the Find Volunteers tab fails to load. Instead, it shows the following error:
'Name' can not be sorted in a query call
This fails in our SoqlListView Apex class, on line 49.
if (SortItemField == null) {
SortItemField = pageController.strNameField;
SortItemAsc = true;
}
if (SortItemField != null) {
strSoql += ' ORDER BY ' + SortItemField + (SortItemAsc ? ' ASC' : ' DESC');
}
strSoql += ' LIMIT 10000';
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(strSoql));
More information about Deterministic Encryption can be found here: Considerations for Using Deterministic Encryption
Key points:
- Case-insensitive deterministic encryption supports compound fields.
- Because deterministic encryption doesn’t maintain the sort order of encrypted data in the database, ORDER BY isn’t supported.
Steps to Repeat:
- Spin up v4s scratch org and run dev_org flow
- Create Permission Set with “Manage Encryption Keys” System Permission. Assign this Permission Set to your User.
- Go to Setup → Key Management. Click the Generate Tenant Secret button.
- Go to Setup —> Advanced Settings. Enable Deterministic Encryption.
- Go to Setup → Key Management and expand the picklist " Choose Tenant Secret Type" and select "Data in Salesforce (Deterministic)" -> "Generate Tenant Secret“
- Go to Setup → Encryption Policy -> "Encrypt Fields" -> select "edit" and then check off the box "Name" under "Contact" and set the picklist value to "Deterministic - Case Insensitive" → "Save"
- Once you receive an email saying the encryption was successful:
- Go to the Find Volunteers tab. Confirm error appears.
- Disabling encryption on the Contact Name field removes the error on the Find Volunteers tab.
For good measure, I tried enabling Probabilistic encryption on Contact Name. It failed due to the following references:
Contact.Name:
Apex Class: VOL_Access_TEST, line 201, column 32: field 'LastName' can not be filtered in a query call
Apex Class: VOL_Access_TEST, line 217, column 32: field 'LastName' can not be filtered in a query call
Apex Class: VOL_CTRL_VolunteersReportHours_TEST, line 161, column 19: field 'Firstname' can not be filtered in a query call
Apex Class: VOL_CTRL_VolunteersReportHours_TEST, line 180, column 19: field 'Firstname' can not be filtered in a query call
Apex Class: VOL_CTRL_VolunteersSignup_TEST, line 93, column 19: field 'Firstname' can not be filtered in a query call
Apex Class: VOL_CTRL_VolunteersSignup_TEST, line 111, column 19: field 'Firstname' can not be filtered in a query call
Apex Class: VOL_CTRL_VolunteersSignup_TEST, line 128, column 19: field 'Firstname' can not be filtered in a query call
Apex Class: VOL_CTRL_VolunteersSignupFS_TEST, line 94, column 19: field 'Firstname' can not be filtered in a query call
Apex Class: VOL_CTRL_VolunteersSignupFS_TEST, line 113, column 19: field 'Firstname' can not be filtered in a query call
Apex Class: VOL_CTRL_VolunteersSignupFS_TEST, line 130, column 19: field 'Firstname' can not be filtered in a query call
Apex Class: VOL_SharedCode, line 314, column 33: field 'Lastname' can not be filtered in a query call
Apex Trigger: VOL_SharedCode, line 314, column 33: field 'Lastname' can not be filtered in a query call```
**lurch: add
Tracking W-040932
**lurch: detach W-040932
**lurch: detach
Detached W-040932
Detached W-040932
**lurch: attach W-025295
Tracking W-025295