Home Salesforce Salesforce Winter 20 Release – Code Enhancement in Apex

Salesforce Winter 20 Release – Code Enhancement in Apex

by Dhanik Lal Sahni

New Apex Classes

These classes were introduced in Winter 20 release.

Formula Class in the System Namespace:

The new System.Formula class contains the recalculateFormulas method that updates (recalculates) all formula fields on the input sObjects.
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.

FormulaRecalcFieldError Class in the System Namespace

The new System.FormulaRecalcFieldError class is the return type of the FormulaRecalcResult.getErrors method. It contains methods that retrieve the name of the error field and a message describing why the formula calculation failed.

FormulaRecalcResult Class in the System Namespace

The new System.FormulaRecalcResult class is the return type of the Formula.recalculateFormulas method. It contains methods that return the sObject with formulas recalculated and errors encountered while recalculating formulas on the sObject.

New Apex Interfaces

Below interfaces were introduced in this release.

TxnSecurity.EventCondition

This interface allows an implementing class to specify whether to take action when certain events occur based on a transaction security policy.

This interface is part of Real-Time Event Monitoring and was beta in Summer ’19.

TxnSecurity.AsyncCondition

This interface allows an implementing class to make asynchronous Apex calls. This interface is part of Real-Time Event Monitoring.

Changed Apex Classes

Below existing classes have new or changed methods or constants.

Auth.SessionManagement Class

New Method verifyDeviceFlow(userCode, startUrl) is added. This method verifies the user code entered during the device authentication flow and redirects users to the OAuth approval page. If users aren’t logged in, they must log in. After successful login, users are prompted to allow the device to access Salesforce data.

EventBus.ChangeEventHeader Class

New Property changedfields is added. This property provide list of the fields that were changed in an update operation, including the LastModifiedDate system field. This field is empty for other operations, including record creation.

System.Type Class

isAssignableFrom(sourceType) method is added to check whether an object of one type can be assigned from an object of another type without instantiating either object. Returns true if the two types are compatible.

System.UserManagement Class

initRegisterVerificationMethod(method) is added to invokes a verification challenge for registering identity verification methods with a custom (Visualforce) page. Users can register either their email address or phone number.

verifyRegisterVerificationMethod(code, method) is added to complete registering a user’s email address or phone number as a verification method when customizing the identity verification process.

ConnectApi (Chatter in Apex):

Many Chatter REST API resource actions are exposed as static methods on Apex classes in the ConnectApi namespace. These methods use other ConnectApi classes to input and return information. The ConnectApi namespace is referred to as Chatter in Apex.

New Chatter in Apex Classes

Below new methods are in the ConnectApi.ManagedContent class.

getAllManagedContent(communityId, pageParam, pageSize, language, managedContentType):  This method will get all managed content versions for a community

getManagedContentByIds(communityId, managedContentIds, pageParam, pageSize, language, managedContentType): This method will get all managed content versions for a community versions by IDs

getManagedContentByTopics(communityId, topics, pageParam, pageSize, language, managedContentType) : This method will get all managed content versions for a community versions by topic names.

getManagedContentByTopicsAndIds(communityId, managedContentIds, topics, pageParam, pageSize, language, managedContentType): This method will get all managed content versions for a community versions by IDs and topic names.

Chatter Feeds

ConnectApi.EmailMessageCapability Class

Below properties are added in this output class.

  • htmlExpandEmailThread—Start location of previous email thread.
  • status—Status of an email message on a case. Values are:
    • DraftStatus
    • ForwardedStatus
    • NewStatus
    • ReadStatus
    • RepliedStatus
    • SentStatus

Communities

ConnectApi.Community class

guestMemberVisibilityEnabled(property) is added which specifies whether guest members can see other members of the community (true) or not (false).

Managed Content

ConnectApi.ManagedContentAssociations class

topics(property) is added which show collection of topics associated with the managed content.

ConnectApi.ManagedContentNodeValue class

This class is added in Winter 20 release. Along with this multiple sub classes are also added for community content management.

  • ConnectApi.ManagedContentMediaNodeValue
  • ConnectApi.ManagedContentNodeType
  • ConnectApi.ManagedContentTextNodeValue
  • ConnectApi.ManagedContentType
  • ConnectApi.ManagedContentVersion
  • ConnectApi.ManagedContentVersionCollection

New Chatter in Apex Enums

ConnectApi.ManagedContentMediaType: Below values is added in this enum.

  • Image

ConnectApi.ManagedContentNodeType: Below enum values are added.

  • Media
  • MultilineText
  • NameField
  • RichText
  • Text

 

Reference : https://releasenotes.docs.salesforce.com/en-us/winter20/release-notes/rn_apex_nc.htm

You may also like

Leave a Comment