Apex: New and Changed Classes and Interfaces

These classes and interfaces are new or have changed.

New Apex Classes

These classes were introduced in this release.
Classes in the System Namespace
Security Class (Pilot)
The new System.Security class contains methods to securely implement Apex applications. Use the methods to remove inaccessible fields before a DML operation without causing an exception and to strip fields that aren’t visible from query results. This pilot feature is available automatically in sandbox, developer, and scratch organizations as a pilot program.
stripInaccessible(accessCheckType, sourceRecords, enforceRootObjectCRUD)
Creates a list of sObjects from the source records, which are stripped of fields that fail the field-level security checks for the current user. The method also provides an option to enforce an object-level access check.
SObjectAccessDecision Class
The new System.SObjectAccessDecision class is the return type of the Security.stripInaccessible method. Based on the specified operation (create, update, or read), this class provides methods to return a list of sObjects that contain only those fields that are accessible to the current user in that context.
Returns the indexes of sObjects that are modified by the stripInaccessible method.
Returns a list of new sObjects that are identical to the source records, except that they are stripped of fields that fail the field-level security check for the current user.
Returns a map of sObject types to their corresponding inaccessible fields. The map key is a string representation of the sObject type. The map value is a set of strings, which denote the fields names that are inaccessible.

Changed Apex Classes

These existing classes have new or changed methods or constants.
Auth.SessionManagement Class
New Methods
Returns the eligibility status for a user who’s logging in with Lightning Login when you set up your org with My Domain and use the Login Discovery page type. Use this method to redirect the user to a custom login flow. For example, use after a login attempt to redirect the user to password flow if the user is ineligible for Lightning Login.
EventBus.TriggerContext Class
New Methods
Returns the replay ID that was set by setResumeCheckpoint(). The returned value is the replay ID of the event message after which trigger processing resumes in a new trigger invocation.
Sets a checkpoint in the event stream where the platform event trigger resumes execution in a new invocation. Use this method to recover from limit and uncaught exceptions, or to control the number of events processed in one trigger execution. When calling this method, pass in the replay ID of the last successfully processed event message. When the trigger stops execution before all events in Trigger.New are processed, either because of an uncaught exception or intentionally, the trigger is invoked again. The new execution starts with the event message in the stream after the one with the checkpointed Replay ID.
Schema.FieldSetMember Class
New Methods
Returns the token for this field.
Schema.SObjectField Class
New Methods
Returns the describe field result for this field. This method also provides an option to get all the describe field results for an object.
System.EventBus Class
New Methods
Returns the ID of the asynchronous event publishing operation based on the passed-in SaveResult. Use this ID to correlate the asynchronous publishing result sent on the /event/AsyncOperationEvent channel.
System.Test Class
New Methods
Use this method in an Apex test so that change event notifications are generated for all supported Change Data Capture entities. Call this method at the beginning of your test before performing DML operations and calling Test.getEventBus().deliver();.
System.UserManagement Class
New Methods
initPasswordlessLogin(userId, method)
Invokes a verification challenge for passwordless login when creating custom (Visualforce) Login and Verify pages for external users.
verifyPasswordlessLogin(userId, method, identifier, code, startUrl)
Completes a verification challenge when creating a custom (Visualforce) Verify page for passwordless login. If the user who is trying to login enters the verification code successfully, the user is logged in.

New Apex Enums

These enumerations were introduced in this release.
AccessType Enum
Specifies the access check type for the fields of an sObject.
LightningLoginEligibility Enum
Contains a Lightning Login eligibility value used by the Auth.SessionManagement.getLightningLoginEligibility method.

Changed Apex Enum

This enumeration was updated in this release.
LoginDiscoveryMethod Enum
Contains methods used to verify the user’s identity when the My Domain login process uses Login Discovery.
This enum has a new value, LIGHTNING_LOGIN. Verify identity by Lightning Login.

New Apex Interface

This interface was introduced in this release.
TxnSecurity.EventCondition Interface (Beta)
Allows an implementing class to specify whether to take action when certain events occur based on a transaction security policy. This interface is only used for Apex policies created in Real-Time Event Monitoring (Beta).
Evaluates an event against a transaction security policy created in Real-Time Event Monitoring (Beta). If the event triggers the policy, the method returns true.