Platform encryption causing compilation failure for apex classes
Apex , API , Platform , Platform Encryption
Last updated 2022-02-10 ·Reference W-3035300 ·Reported By 2 users
Summary
Executing a SOQL to filter out a field which is not an abstract type, like the Preferences field of the CustomObjectTeamRole entity, results in a NullPointerException if encryption is enabled on an org.
Repro
Enable encryption in an Org.
Scenario 1:
===========
1. Run the following SOQL through workbench/dev console.
SELECT Id FROM CaseTeamRole WHERE PreferencesVisibleInCSP = true
You will get "UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: 387187816-1545 (2125913720)", and will see a NullPointerException in a log file.
Scenario 2:
===========
Open the existing class having similar query.
e.g. SELECT Id FROM CaseTeamRole WHERE PreferencesVisibleInCSP = true
- The apex class will fail compilation and will not open.
Workaround
Avoid filters on non abstract type fields. Update query like below and use the apex code to handle the PreferencesVisibleInCSP field.
SELECT Id, PreferencesVisibleInCSP FROM CaseTeamRole
Reported By (2)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.