New and Changed Apex Classes

These classes, methods, annotations, and interfaces are new or have changed in this release.

New Methods

The following existing classes have new methods.

DataSource.Column Class
integer(name, length)
Returns a new numeric column with no decimal places using the specified name and length.
DataSource.Connection Class
deleteRows(deleteContext)
Invoked when external object records are deleted via the Salesforce user interface, APIs, or Apex.
upsertRows(upsertContext)
Invoked when external object records are created or updated via the Salesforce user interface, APIs, or Apex.
Messaging.SingleEmailMessage Class
The following method has been deprecated
setDocumentAttachments(documentIds)
Deprecated. Use setEntityAttachments() instead.
The following methods have been added.
setEntityAttachments(ids)
Optional. Array of IDs of Document or ContentVersion items to attach to the email.
setOptOutPolicy(emailOptOutPolicy)
Optional. If you added recipients by ID instead of email address and the Email Opt Out option is set, this method determines the behavior of the sendEmail() call. If you add recipients by their email addresses, the opt-out settings for those recipients aren’t checked and those recipients always receive the email.
setTreatBodiesAsTemplate(treatAsTemplate)
Optional. If set to true, the subject, plain text, and HTML text bodies of the email are treated as template data.
setTreatTargetObjectAsRecipient(treatAsRecipient)
Optional. If set to true, the targetObjectId (a contact, lead, or user) is the recipient of the email. If set to false, the targetObjectId is supplied as the WhoId field for template rendering but isn’t a recipient of the email. The default is true.
QuickAction.DescribeAvailableQuickActionResult Class
getActionEnumOrId()
Returns the unique ID for the action. If the action doesn’t have an ID, its API name is used.
QuickAction.DescribeLayoutSection Class
getParentLayoutId()
Returns the ID of the layout upon which this DescribeLayoutSection resides.
QuickAction.DescribeQuickActionResult Class
getActionEnumOrId()
Returns the unique ID for the action. If the action doesn’t have an ID, its API name is used.
reports.ReportMetadata Class
getDescription()
Returns the description of the report.
reports.ReportMetadata Class
getShowGrandTotal()
Indicates whether the report shows the grand total.
reports.ReportMetadata Class
getShowSubtotals()
Indicates whether the report shows subtotals, such as column or row totals.
reports.ReportMetadata Class
setDescription(description)
Sets the description of the report.
reports.ReportMetadata Class
setShowGrandTotal(showGrandTotal)
Specifies whether the report shows the grand total.
reports.ReportMetadata Class
setShowSubtotals(showSubtotals)
Specifies whether the report shows subtotals, such as column or row totals.
Schema.DescribeTabSetResult Class
getDescription()
Returns the display description for the standard or custom app.
Schema.RecordTypeInfo Class
isMaster()
Returns true if this is the master record type and false otherwise. The master record type is the default record type that’s used when a record has no custom record type associated with it.
System.Approval Class
lock(recordId)
Locks an object, and returns the lock results.
lock(recordIds)
Locks a set of objects, and returns the lock results, including failures.
lock(recordToLock)
Locks an object, and returns the lock results.
lock(recordsToLock)
Locks a set of objects, and returns the lock results, including failures.
lock(recordId, allOrNothing)
Locks an object, with the option for partial success, and returns the lock result.
lock(recordIds, allOrNothing)
Locks a set of objects, with the option for partial success. It returns the lock results, including failures.
lock(recordToLock, allOrNothing)
Locks an object, with the option for partial success, and returns the lock result.
lock(recordsToLock, allOrNothing)
Locks a set of objects, with the option for partial success. It returns the lock results, including failures.
unlock(recordId)
Unlocks an object, and returns the unlock results.
unlock(recordIds)
Unlocks a set of objects, and returns the unlock results, including failures.
unlock(recordToUnlock)
Unlocks an object, and returns the unlock results.
unlock(recordsToUnlock)
Unlocks a set of objects, and returns the unlock results, including failures.
unlock(recordId, allOrNothing)
Unlocks an object, with the option for partial success, and returns the unlock result.
unlock(recordIds, allOrNothing)
Unlocks a set of objects, with the option for partial success. It returns the unlock results, including failures.
unlock(recordToUnlock, allOrNothing)
Unlocks an object, with the option for partial success, and returns the unlock result.
unlock(recordsToUnlock, allOrNothing)
Unlocks a set of objects, with the option for partial success. It returns the unlock results, including failures.
System.Database Class
deleteAsync(sobject, callback)
Initiates a request to delete the external data that corresponds to the specified external object record. The request is executed asynchronously, as a background operation, and is sent to the external system that's defined by the external object's associated external data source. Allows referencing a callback class whose processDelete method is called after deletion.
deleteAsync(sobjects, callback)
Initiates requests to delete the external data that corresponds to the specified external object records. The request is executed asynchronously, as a background operation, and is sent to the external system that's defined by the external object's associated external data source. Allows referencing a callback class whose processDelete method is called for each record after deletion.
deleteAsync(sobject)
Initiates a request to delete the external data that corresponds to the specified external object record. The request is executed asynchronously, as a background operation, and is sent to the external system that's defined by the external object's associated external data source.
deleteAsync(sobjects)
Initiates requests to delete the external data that corresponds to the specified external object records. The requests are executed asynchronously, as background operations, and are sent to the external systems that are defined by the external objects' associated external data sources.
deleteImmediate(sobject)
Initiates a request to delete the external data that corresponds to the specified external object record. The request is executed synchronously and is sent to the external system that's defined by the external object's associated external data source. If the Apex transaction contains pending changes, the synchronous operation can't be completed and throws an exception.
deleteImmediate(sobjects)
Initiates requests to delete the external data that corresponds to the specified external object records. The requests are executed synchronously and are sent to the external systems that are defined by the external objects' associated external data sources. If the Apex transaction contains pending changes, the synchronous operations can't be completed and throw exceptions.
getAsyncDeleteResult(asyncLocator)
Retrieves the result of an asynchronous delete operation based on the result’s unique identifier.
getAsyncDeleteResult(deleteResult)
Retrieves the status of an asynchronous delete operation that’s identified by a Database.DeleteResult object.
getAsyncLocator(result)
Returns the asyncLocator associated with the result of a specified asynchronous insert, update, or delete operation.
getAsyncSaveResult(asyncLocator)
Returns the status of an asynchronous insert or update operation based on the unique identifier associated with each modification.
getAsyncSaveResult(saveResult)
Returns the status of an asynchronous insert or update operation that’s identified by a Database.SaveResult object.
insertAsync(sobject)
Initiates a request to add external object data to the relevant external system. The request is executed asynchronously, as a background operation, and is sent to the external system that's defined by the external object's associated external data source.
insertAsync(sobjects)
Initiates requests to add external object data to the relevant external systems. The requests are executed asynchronously, as background operations, and are sent to the external systems that are defined by the external objects' associated external data sources.
insertAsync(sobject, callback)
Initiates a request to add external object data to the relevant external system. The request is executed asynchronously, as a background operation, and is sent to the external system that's defined by the external object's associated external data source. Allows referencing a callback class whose processSave method is called after the remote operation is completed.
insertAsync(sobjects, callback)
Initiates requests to add external object data to the relevant external systems. The requests are executed asynchronously, as background operations, and are sent to the external systems that are defined by the external objects' associated external data sources. Allows referencing a callback class whose processSave method is called for each record after the remote operations are completed.
insertImmediate(sobject)
Initiates a request to add external object data to the relevant external system. The request is executed synchronously and is sent to the external system that's defined by the external object's associated external data source. If the Apex transaction contains pending changes, the synchronous operation can't be completed and throws an exception.
insertImmediate(sobjects)
Initiates requests to add external object data to the relevant external systems. The requests are executed synchronously and are sent to the external systems that are defined by the external objects' associated external data sources. If the Apex transaction contains pending changes, the synchronous operations can't be completed and throw exceptions.
updateAsync(sobject)
Initiates a request to update external object data on the relevant external system. The request is executed asynchronously, as a background operation, and is sent to the external system that's defined by the external object's associated external data source.
updateAsync(sobjects)
Initiates requests to update external object data on the relevant external systems. The requests are executed asynchronously, as background operations, and are sent to the external systems that are defined by the external objects' associated external data sources.
updateAsync(sobject, callback)
Initiates a request to update external object data on the relevant external system. The request is executed asynchronously, as a background operation, and is sent to the external system that's defined by the external object's associated external data source. Allows referencing a callback class whose processSave method is called after the remote operation is completed.
updateAsync(sobjects, callback)
Initiates requests to update external object data on the relevant external systems. The requests are executed asynchronously, as background operations, and are sent to the external systems that are defined by the external objects' associated external data sources. Allows referencing a callback class whose processSave method is called for each record after the remote operations are completed.
updateImmediate(sobject)
Initiates a request to update external object data on the relevant external system. The request is executed synchronously and is sent to the external system that's defined by the external object's associated external data source. If the Apex transaction contains pending changes, the synchronous operation can't be completed and throws an exception.
updateImmediate(sobjects)
Initiates requests to update external object data on the relevant external systems. The requests are executed synchronously and are sent to the external systems that are defined by the external objects' associated external data sources. If the Apex transaction contains pending changes, the synchronous operations can't be completed and throw exceptions.
System.Network Class
loadAllPackageDefaultNetworkPulseSettings()
Maps the Insights reports from the Salesforce Communities Dashboards package onto each community’s unconfigured Insights settings. Returns the number of settings it configures.
System.SObject Class
getCloneSourceId()
Returns the ID of the entity from which an object was cloned. You can use it for objects cloned through the Salesforce user interface. If you don’t use a preserveId parameter, of if you use a preserveId value of false, you can also used it for objects created using the System.SObject.clone(preserveId, isDeepClone, preserveReadonlyTimestamps, preserveAutonumber) method.
isClone()
Returns true if an entity is cloned from something, even if the entity hasn’t been saved.
recalculateFormulas()
Recalculates all formula fields on an sObject, and sets updated field values. Rather than inserting or updating objects each time you want to test changes to your formula logic, call this method and inspect your new field values. Then make further logic changes as needed.
System.Test Class
enqueueBatchJobs(numberOfJobs)
Adds the specified number of jobs with no-operation contents to the test-context queue. It first fills the test batch queue, up to the maximum 5 jobs, and then places jobs in the test flex queue. It throws a limit exception when the number of jobs in the test flex queue exceeds the allowed limit of 100 jobs.
getFlexQueueOrder()
Returns an ordered list of job IDs for jobs in the test-context flex queue. The job at index 0 is the next job slated to run. This method returns only test-context results, even if it’s annotated with @IsTest(SeeAllData=true).

New Properties

The following classes have new properties.

Reports.ReportMetadata Class
showGrandTotal
Indicates whether the report shows the grand total.
showSubtotals
Indicates whether the report shows subtotals, such as column or row totals.

Updated Enums

The following enum has been updated.

DataSource.Capability Enum
ROW_CREATE, ROW_UPDATE, and ROW_DELETE Values
Enum values have been added to indicate whether external data can be created, updated, and deleted in the external system.

New Classes

The following classes have been added.

AppMenu Class in the AppLauncher Namespace
The new AppLauncher.AppMenu class sets the appearance of apps and items in the App Launcher. This class has the following methods.
setAppVisibility(appMenuItemId, isVisible)
Shows or hides specific apps in the App Launcher.
setOrgSortOrder(appIds)
Sets the organization-wide default sort order for the App Launcher based on a List of app menu item IDs in the desired order.
setUserSortOrder(appIds)
Sets an individual user’s default sort order for the App Launcher based on a List of app menu item IDs in the desired order.
Classes in the Approval Namespace
Approval.LockResult Class
The new Approval.LockResult class contains methods that show the results of record locks placed by System.Approval.lock() methods.
getErrors()
If an error occurred, returns an array of one or more database error objects, providing the error code and description.
getId()
Returns the ID of the sObject you are trying to lock.
isSuccess()
A Boolean value that is set to true if the lock operation is successful for this object, or false otherwise.
Approval.UnlockResult Class
The new Approval.UnlockResult class contains methods that show the results of record unlocks by System.Approval.unlock() methods.
getErrors()
If an error occurred, returns an array of one or more database error objects, providing the error code and description.
getId()
Returns the ID of the sObject you are trying to unlock.
isSuccess()
A Boolean value that is set to true if the unlock operation is successful for this object, or false otherwise.
ConnectedAppPlugin Class in the Auth Namespace
The new Auth.ConnectedAppPlugin class lets you customize the behavior of a connected app. This class has the following methods.
authorize(userId, connectedAppId, isAdminApproved)
Authorizes the specified user for the connected app.
customAttributes(userId, formulaDefinedAttributes)
Sets new attributes for the specified user. When the connected app gets the user’s attributes from the UserInfo endpoint or through a SAML assertion, use this method to update those attribute values.
refresh(userId, connectedAppId)
Salesforce calls this method during a refresh token exchange.
Classes in the Cache Namespace
Cache.Org Class
Use the Cache.Org class to add, retrieve, and manage values in the org cache. Unlike the session cache, the org cache is not tied to any session and is available to the organization across requests and to all users. This class has the following methods.
contains(keys)
Returns true if the org cache contains the specified key entries.
contains(key)
Returns true if the org cache contains a cached value corresponding to the specified key.
get(key)
Returns the cached value corresponding to the specified key from the org cache.
getCapacity()
Returns the percentage of org cache capacity that has been used.
getKeys()
Returns a set of all keys that are stored in the org cache and visible to the invoking namespace.
getPartition(partitionName)
Returns a partition from the org cache that corresponds to the specified partition name.
put(key, value, ttlSecs, visibility, immutable)
Stores the specified key/value pair as a cached entry in the org cache. This method also sets the cached value’s lifetime, visibility, and whether it can be overwritten by another namespace.
put(key, value, ttlSecs)
Stores the specified key/value pair as a cached entry in the org cache and sets the cached value’s lifetime.
put(key, value, visibility)
Stores the specified key/value pair as a cached entry in the org cache and sets the cached value’s visibility.
put(key, value)
Stores the specified key/value pair as a cached entry in the org cache. The put method can write only to the cache in your org’s namespace.
remove(key)
Deletes the cached value corresponding to the specified key from the org cache.
Cache.OrgPartition Class
Contains methods to manage cache values in the org cache of a specific partition. Unlike the session cache, the org cache is not tied to any session. It’ss available to the organization across requests and to all users. This class inherits all of its methods from the Cache.Partition class. The only exceptions are the utility methods for creating and validating keys, which are supported only in Cache.Partition.
Cache.Partition Class
Base class of Cache.OrgPartition and Cache.SessionPartition. Use the subclasses to manage the cache partition for org caches and session caches. This class has the following methods.
contains(key)
Returns true if the cache partition contains a cached value corresponding to the specified key.
createFullyQualifiedKey(namespace, partition, key)
Generates a fully qualified key from the passed-in key components. The format of the generated key string is namespace.partition.key.
createFullyQualifiedPartition(namespace, partition)
Generates a fully qualified partition name from the passed-in namespace and partition. The format of the generated partition string is namespace.partition.
get(key)
Returns the cached value corresponding to the specified key from the cache partition.
getCapacity()
Returns the percentage of cache used of the total capacity for this partition.
getKeys()
Returns the cached value corresponding to the specified key from the cache partition.
getName()
Returns the name of this cache partition.
isAvailable()
Returns true if the Salesforce session is available. Only applies to Cache.SessionPartition.
put(key, value, ttlSecs, visibility, immutable)
Stores the specified key/value pair as a cached entry in the cache partition. This method also sets the cached value’s lifetime, visibility, and whether it can be overwritten by another namespace.
put(key, value, ttlSecs)
Stores the specified key/value pair as a cached entry in the cache partition and sets the cached value’s lifetime.
put(key, value, visibility)
Stores the specified key/value pair as a cached entry in the cache partition and sets the cached value’s visibility.
put(key, value)
Stores the specified key/value pair as a cached entry in the session cache. The put method can write only to the cache in your org’s namespace.
remove(key)
Deletes the cached value corresponding to the specified key from this cache partition.
validateKey(isDefault, key)
Validates the specified cache keys. This method throws a Cache.InvalidParamException if the key is not valid. A valid key is not null and contains alphanumeric characters.
validateKeyValue(isDefault, key, value)
Validates a cache key and ensures that the cache value is non-null. This method throws a Cache.InvalidParamException if the key or value is not valid. A valid key is not null and contains alphanumeric characters.
validateKeys(isDefault, keys)
Validates the specified cache keys. This method throws a Cache.InvalidParamException if the key is not valid. A valid key is not null and contains alphanumeric characters.
validatePartitionName(name)
Validates the partition name — for example, that it is not null.
Cache.Session Class
Use the Cache.Session class to add, retrieve, and manage values in the session cache. The session cache is active as long as the user’s Salesforce session is valid (the user is logged in and the session is not expired). This class has the following methods.
contains(key)
Returns true if the session cache contains a cached value corresponding to the specified key.
get(key)
Returns the cached value corresponding to the specified key from the session cache.
getCapacity()
Returns the percentage of session cache capacity that has been used.
getKeys()
Returns all keys that are stored in the session cache and visible to the invoking namespace.
getPartition(partitionName)
Returns a partition from the session cache that corresponds to the specified partition name.
isAvailable()
Returns true if the session cache is available for use.
put(key, value, ttlSecs, visibility, immutable)
Stores the specified key/value pair as a cached entry in the session cache. This method also sets the cached value’s lifetime, visibility, and whether it can be overwritten by another namespace.
put(key, value, ttlSecs)
Stores the specified key/value pair as a cached entry in the session cache and sets the cached value’s lifetime.
put(key, value, visibility)
Stores the specified key/value pair as a cached entry in the session cache and sets the cached value’s visibility.
put(key, value)
Stores the specified key/value pair as a cached entry in the session cache. The put method can write only to the cache in your org’s namespace.
remove(key)
Deletes the cached value corresponding to the specified key from the session cache.
Cache.SessionPartition Class
Contains methods to manage cache values in the session cache of a specific partition. This class inherits all of its methods from the Cache.Partition class. The only exceptions are the utility methods for creating and validating keys, which are supported only in Cache.Partition.
Classes in the DataSource Namespace
AsyncDeleteCallback Class
A callback class that the Database.deleteAsync method references. Salesforce calls this class after the remote deleteAsync operation is completed. This class provides the compensating transaction in the completion context of the delete operation. Extend this class to define the actions to execute after the remote delete operation finishes execution. This class has the following methods.
processDelete(deleteResult)
Override this method to define actions that Salesforce executes after a remote Database.deleteAsync operation is completed. For example, based on the results of the remote operation, you can update custom object data or other data that's stored in the Salesforce org..
AsyncSaveCallback Class
A callback class that the Database.insertAsync or Database.updateAsync method references. Salesforce calls this class after the remote operation is completed. This class provides the compensating transaction in the completion context of the insert or update operation. Extend this class to define the actions to execute after the remote insert or update operation finishes execution. This class has the following methods.
processSave(saveResult)
Override this method to define actions that Salesforce executes after the remote Database.insertAsync or Database.updateAsync operation is completed. For example, based on the results of the remote operation, you can update custom object data or other data that's stored in the Salesforce org.
DeleteContext Class
An instance of DeleteContext is passed to the deleteRows() method on your Database.Connection class. The class provides context information about the delete request to the implementor of deleteRows(). This class has the following properties.
externalIds
The external IDs of the rows representing external object records to delete.
tableSelected
The name of the table to delete rows from.
DeleteResult Class
An instance of DeleteContext is passed to the deleteRows() method on your Database.Connection class. The class provides context information about the delete request to the implementor of deleteRows(). This class has the following methods and properties.
equals(obj)
Maintains the integrity of lists of type DeleteResult by determining the equality of external objects in a list. This method is dynamic and is based on the equals method in Java.
errorMessage property
The error message that’s generated by a failed delete operation. Recorded with a result of type DataSource.DeleteResult.
externalId property
The unique identifier of a row that represents an external object record to delete.
failure(externalId, errorMessage)
Creates a delete result indicating the failure of a delete request for a given external ID.
hashCode()
Maintains the integrity of lists of type DeleteResult by determining the uniqueness of the external object records in a list.
success(externalId)
Creates a delete result indicating the successful completion of a delete request for a given external ID.
success property
Indicates whether a delete operation succeeded or failed.
UpsertContext Class
An instance of UpsertContext is passed to the upsertRows() method on your Datasource.Connection class. This class provides context information about the upsert request to the implementor of upsertRows(). This class has the following properties.
rows
List of rows corresponding to the external object records to upsert.
tableSelected
The name of the table to upsert rows in.
UpsertResult Class
Represents the result of an upsert operation on an external object record. The result is returned by the upsertRows method of the DataSource.Connection class. This class has the following methods and properties.
equals(obj)
Maintains the integrity of lists of type UpsertResult by determining the equality of external object records in a list. This method is dynamic and is based on the equals method in Java.
errorMessage property
The error message that’s generated by a failed upsert operation.
externalId property
The unique identifier of a row that represents an external object record to upsert.
failure(externalId, errorMessage)
Creates an upsert result that indicates the failure of a delete request for a given external ID.
hashCode()
Maintains the integrity of lists of type UpsertResult by determining the uniqueness of the external object records in a list.
success(externalId)
Creates a delete result that indicates the successful completion of an upsert request for a given external ID.
success property
Indicates whether a delete operation succeeded or failed.
System
FlexQueue Class in the System Namespace
The new System.FlexQueue class contains methods that reorder jobs in the Apex flex queue.
moveAfterJob(jobToMoveId, jobInQueueId)
Moves the job with the ID jobToMoveId immediately after the job with the ID jobInQueueId in the flex queue. You can move jobToMoveId forward or backward in the queue. If either job isn’t in the queue, it throws an element-not-found exception. Returns true if the job is moved, or false if jobToMoveId is already immediately after jobInQueueId, so no change is made.
moveBeforeJob(jobToMoveId, jobInQueueId)
Moves the job with the ID jobToMoveId immediately before the job with the ID jobInQueueId in the flex queue. You can move jobToMoveId forward or backward in the queue. If either job isn’t in the queue, it throws an element-not-found exception. Returns true if the job is moved, or false if jobToMoveId is already immediately before jobInQueueId, so no change is made.
moveJobToEnd(jobId)
Moves the specified job the end of the flex queue, to index position (size - 1). All jobs after the job’s starting position move one spot forward. If the job isn’t in the queue, it throws an element-not-found exception. Returns true if the job is moved, or false if the job is already at the end of the queue, so no change is made.
moveJobToFront(jobId)
Moves the specified job to the front of the flex queue, to index position 0. All other jobs move back one spot. If the job isn’t in the queue, it throws an element-not-found exception. Returns true if the job is moved, or false if the job is already at the front of the queue, so no change is made.
QuestionSuggestionFilter Class in the Search Namespace
The new Search.QuestionSuggestionFilter class filters results from a call to System.Search.suggest(searchQuery, sObjectType, options) when the SOSL searchQuery contains a FeedItem object. This class has the following methods.
addGroupId(groupId)
Adds a filter to display questions associated with the single specified group whose ID is passed in as an argument. This filter is optional.
addNetworkId(networkId)
Adds a filter to display questions associated with the single specified network whose ID is passed in as an argument. This filter is optional.
addUserId(userId)
Adds a filter to display questions belonging to the single specified user whose ID is passed in as an argument. This filter is optional.
setGroupIds(groupIds)
Sets a new list of groups to replace the current list of groups where the group IDs are passed in as an argument. This filter is optional.
setNetworkIds(networkIds)
Sets a new list of networks to replace the current list of networks where the network IDs are passed in as an argument. This filter is optional.
setTopicId(topicId)
Sets a filter to display questions associated with the single specified topic whose ID is passed in as an argument. This filter is optional.
setUserIds(userIds)
Sets a new list of users to replace the current list of users where the users IDs are passed in as an argument. This filter is optional.
PolicyCondition Interface in the TxnSecurity Namespace
Implement the new PolicyCondition interface to specify actions to take when certain events occur based on a transaction security policy. This interface has the following method.
evaluate(event)
Evaluates an event against a transaction security policy. If the event triggers the policy, true is returned.
As part of this new interface, the Event class has been added. The Event class contains event information that the PolicyCondition.evaluate method uses to evaluate a transaction security policy.

Objects That Support Triggers

You can now create triggers for the following objects:
  • ContentDistribution
  • ContentDocumentLink

See Create Triggers to Customize File Sharing Behavior.