Volunteers-for-Salesforce icon indicating copy to clipboard operation
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

Open jesslopez-sf opened this issue 4 years ago • 8 comments

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```

jesslopez-sf avatar Apr 20 '20 20:04 jesslopez-sf

**lurch: add

jesslopez-sf avatar Apr 20 '20 20:04 jesslopez-sf

Tracking W-040932

LurchTheButler avatar Apr 20 '20 21:04 LurchTheButler

**lurch: detach W-040932

jesslopez-sf avatar May 15 '20 13:05 jesslopez-sf

**lurch: detach

jesslopez-sf avatar May 15 '20 13:05 jesslopez-sf

Detached W-040932

LurchTheButler avatar May 15 '20 13:05 LurchTheButler

Detached W-040932

LurchTheButler avatar May 15 '20 13:05 LurchTheButler

**lurch: attach W-025295

jesslopez-sf avatar May 15 '20 13:05 jesslopez-sf

Tracking W-025295

LurchTheButler avatar May 15 '20 13:05 LurchTheButler