Apex: New and Changed Classes, Enums, and Interfaces

These classes, enums, and interfaces are new or have changed.

New Apex Classes

These classes are introduced in this release.
TestBroker Class in the EventBus Namespace
The new EventBus.TestBroker class contains a method that delivers platform event messages in an Apex test.
deliver()
Delivers platform event messages to the test event bus. Use this method to deliver test event messages multiple times and verify that event subscribers have processed the test events each step of the way.
UserManagement Class in the System Namespace
The new System.UserManagement class contains methods to manage end users, for example, to register verification methods or handle requests for Salesforce to forget them.
deregisterVerificationMethod(userId, method)
Deregisters an identity verification method. Use this method to allow users to delete an existing verification method.
formatPhoneNumber(countryCode, phoneNumber)
Formats a mobile phone number for a user. Call this method to ensure that the phone number is formatted properly before updating a user’s mobile phone number.
obfuscateUser(userId)
Scrambles users’ data on their request when they no longer want their personal data recognized in Salesforce. When you invoke the method for the user, the data becomes anonymous, and you can never recover it.
obfuscateUser(userId, username)
Scrambles users’ data on their request when they no longer want their personal data recognized in Salesforce. When you invoke the method for the user, the data becomes anonymous, and you can never recover it. Use this method to set the username to a specific value after it’s scrambled.
registerVerificationMethod(method, startUrl)
Registers an identity verification method. Verification methods include a time-based one-time password, email or text one-time password, Salesforce Authenticator, or U2F. End users register their verification methods.

Changed Apex Classes

These existing classes have new or changed methods or constants.
Schema.DescribeFieldResult Class
New Method
isAiPredictionField() (Beta)
Returns a Boolean indicating whether the field is enabled to display Einstein prediction data.
New Method
isFormulaTreatNullNumberAsZero(}
Returns true if null is treated as zero in a formula field, false otherwise.
Schema.DescribeSObjectResult Class
New Method
getRecordTypeInfosByDeveloperName()
Returns a map that matches developer names to their associated record type.
Schema.RecordTypeInfo Class
New Method
getDeveloperName()
Returns the developer name for this record type.
System.Site Class
New Method
passwordlessLogin(userId, methods, startUrl)
Logs in a user to a community using an identity verification method, such as email or text, instead of a password. Passwordless login is a convenient, mobile-friendly way to welcome users into your community. Give your community users an alternative to requiring passwords when they log in.
System.Test Class
New Method
clearApexPageMessages()
Clear the messages on a Visualforce page while executing Apex test methods.
New Method
getEventBus()
Returns an instance of the test event bus broker, which lets you operate on platform event messages in an Apex test. For example, you can call Test.getEventBus().deliver() to deliver event messages.

New Apex Enums

These enumerations are introduced in this release.
Auth.VerificationMethod Enum
This enum has the following values, which correspond to identity verification methods.
  • EMAIL
  • SALESFORCE_AUTHENTICATOR
  • SMS
  • TOTP
  • U2F
System.TriggerOperation Enum
This enum has the following values, which correspond to trigger events.
  • AFTER_DELETE
  • AFTER_INSERT
  • AFTER_UNDELETE
  • AFTER_UPDATE
  • BEFORE_DELETE
  • BEFORE_INSERT
  • BEFORE_UPDATE

Changed Apex Interface

This section lists existing interfaces that have been updated.
QuickAction.QuickActionDefaultsHandler Interface
Changed Methods
The QuickAction.QuickActionDefaultsHandler interface lets you specify the default values for the standard Email action in the case feed. This interface now works in Lightning Experience. For support details, see the Apex Developer Guide.