Salesforce Winter 21 release note for developers

Apex:-

Use the Safe Navigation Operator to Avoid Null Pointer Exceptions

Use the safe navigation operator (?.) to replace explicit, sequential checks for null references. This new operator short-circuits expressions that attempt to operate on a null value and returns null instead of throwing a NullPointerException.

Example
  • This example first evaluates a, and returns null if a is null. Otherwise, the return value is a.b.
a?.b // Evaluates to: a == null? Null : a.b
  • This example shows a single statement replacing a block of code that checks for nulls.
// Previous code checking for nulls
String profileUrl = null;
if (user.getProfileUrl() != null) {
	profileUrl = user.getProfileUrl().toExternalForm();
	}
// New code using the safe navigation operator
String profileUrl = user.getProfileUrl()?.toExternalForm();
  • This example shows a single-row SOQL query using the safe navigation operator.
// Previous code checking for nulls
results = [SELECT Name FROM Account WHERE Id = :accId];
if (results.size() == 0) { // Account was deleted
    return null;
}
return results[0].Name;
// New code using the safe navigation operator
return [SELECT Name FROM Account WHERE Id = :accId]?.Name;
Update Resources with the PATCH HTTP Method in Apex Callouts
  • To make partial or full updates to a resource in an HTTP web service, specify the PATCH method in the HttpRequest class. Previously, only the PUT method was supported for full updates.
Send Custom Notifications from Apex
  • Use the Messaging.CustomNotification class to create, configure, and send custom notifications directly from Apex code, such as a trigger.
Improve Apex Testing with New SObject Error Methods
  • Track error with the new SObject.hasErrors() and SObject.getErrors() methods without performing a DML operation to check the result for errors. Dynamically add errors to specific fields with new SObject.addError() overload methods. Use the hasErrors() method to know if an SObject instance contains errors. Use the getErrors() method to retrieve the list of errors for a specific SObject instance.
This example code shows usage of the new SObject error methods.
//Baseline code sample for using addError, getErrors, together
   Account a = new Account();
   String msg = 'New error method in SObject';
   //The new overload that accepts the field dynamically at runtime
   a.addError('Name', msg); 
   List<Database.Error> errors = a.getErrors();
   System.assertEquals(1, errors.size());
   Database.Error error = errors.get(0);
   System.assertEquals(msg, error.getMessage());
   System.assertEquals(StatusCode.FIELD_CUSTOM_VALIDATION_EXCEPTION, error.getStatusCode());
   String[] fields = error.getFields();
   System.assertNotEquals(null, fields);
   System.assertEquals(1, fields.size());
Delete up to 50,000 Big Object Records in a Batch
  • The Database.deleteImmediate() method now supports batch deletes of up to 50,000 big object records at once. This new limit matches the total number of records you can retrieve with a SOQL query.

LWC(Lightning Web Component)

lightning/uiObjectInfoApi
  • The getObjectInfos wire adapter is new. Use getObjectInfos to get metadata for multiple objects. The response includes metadata describing fields, child relationships, record type, and theme for each object.
import { LightningElement, wire } from 'lwc';
import { getObjectInfos } from 'lightning/uiObjectInfoApi';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import OPPORTUNITY_OBJECT from '@salesforce/schema/Opportunity';

export default class GetObjectInfosExample extends LightningElement {
    @wire(getObjectInfos, { objectApiNames: [ ACCOUNT_OBJECT, OPPORTUNITY_OBJECT ] })
    propertyOrFunction;
}
lightning/uiRecordApi
  • The getRecordNotifyChange() function is new. Call getRecordNotifyChange() to refresh the Lightning Data Service cache after you update a record outside of its mechanisms, such as via imperative Apex, Visualforce, or when you call User Interface API via a third-party framework. Lightning Data Service fetches record updates for the record IDs you specify and refreshes your Lightning Data Service cache, providing your wires with the latest record data.
import { LightningElement, wire } from 'lwc';
import { getRecord, getRecordNotifyChange } from 'lightning/uiRecordApi';
import apexUpdateRecord from '@salesforce/apex/Controller.apexUpdateRecord';
 
export default class NotifyRecordChangeExample extends LightningElement {
    @api recordId;
 
    // Wire a record.
    @wire(getRecord, { recordId: '$recordId', fields: ... })
    record;
 
    async handler() {
      // Update the record via Apex.
      await apexUpdateRecord(this.recordId);
      // Notify LDS that you've changed the record outside its mechanisms.
      getRecordNotifyChange([{recordId: this.recordId}]);
    }
}

VisualForce Pages

New Attribute on <apex:inputField> Overrides Entity Edit Permissions
  • The new ignoreEditPermissionForRendering attribute on <apex:inputField> allows you to override entity edit permissions for users, even when the underlying permission on the object doesn’t allow edits.

Which feature you like most. Comment below why and how gonna help you out in development. Comment also if you know other features.

I hope you have enjoyed the article. You can comment below, If you have any queries related above topic. Subscribe our blog for the latest updates.

Follow us on twitter and join our WhatsApp group.