Skip links

Salesforce Summer ’23 Release: Must-Know Updates for Developers

Salesforce Summer ’23 release weekends are not far away. Let’s go through the cool updates that any Salesforce developer shouldn’t miss.

1. Iterable Interface with Set Type

The good news is that theSet class now implements the Iterable interface, so you can directly iterate over sets. Both sets and lists are iterable, allowing for more code reuse. As a result, you needn’t do a lot of workarounds to use Sets and Lists. You can just use String.join() with sets, as they are Iterable now.

Set<String> letters = new Set<String>{'a','b','c','d'};

System.debug(String.join(letters, '...'));

So, if you are using something like this:  

List<String> someNonUniqueStringList = new List<String>{‘Tokio’, ‘Madrid’, ‘London’, ‘Tokio’}; Set <String> uniqueStringSet = new Set<String>( someNonUniqueStringList ); //uniqueStringSet -->‘Tokio’, ‘Madrid’, ‘London’

you don’t have to reinitialize the List.

2. New LWC directive lwc:spread={childProps}

The lwc:spread={childProps} spreads properties to a child component, enabling elements to accept an object’s keys bound as properties at runtime.

Let’s see how it works. Firstly, we need to define the object with keys as the property names and values:

// app.js
import { LightningElement } from 'lwc';

export default class extends LightningElement {
    childProps = { name: 'Codey Bear', country: 'USA' };
}

Then we need to apply childProps as a property to the child component:

<!-- app.html -->
<template>
    <c-child lwc:spread={childProps}></c-child>
</template>

After that, we should use the properties on the child component:

<!-- child.html -->
<template>
  <p>Name: {name}</p>
  <p>Country : {country} </p>
</template>

This feature actually gives you a lot of flexibility in writing web components. Now you can dynamically describe your components with all needed attributes right in JS. This can increase code reusability allowing us to store and locate some bunch of attributes in a separate file for constants for generic usage purpose. It will result in a much cleaner code.

3. Five Levels of Parent-to-Child Relationships in SOQL Queries

From Summer ’23 release, you can traverse up to five levels of parent-child records while querying data in SOQL. Use a single SOQL query to get parent-child records from five different levels. This ability is limited to SOQL queries via the REST and SOAP query calls on standards and custom objects.

SELECT Name,
    (SELECT LastName,
        (SELECT AssetLevel,
            (SELECT Description,
                (SELECT LineItemNumber FROM WorkOrderLineItems)    
            FROM WorkOrders)    
        FROM Assets)    
    FROM Contacts)    
FROM Account

This innovation sounds wonderful because previously there were such limitations as “SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object”. And this change can make make a developer’s life a lot easier.

4. Dynamical Access of Labels in Apex

Now you can use the System.Label.get(namespace, label, language) method to get a custom label, optionally specifying a language. This feature allows dynamic resolution of label names at run time, including overriding the user’s current language if a translation exists for the requested language. 

Previously, retrieving labels required compile-time knowledge of the label API name. For example, if you had a label with the API name ‘welcome_text’, you could use it like System.Label.welcome_text.

Moreover, you can also check if the translation exists for a label and language in a namespace by using Label.translationExists(namespace, label, language).

This feature has increased the ability to add user-friendly functionality for multi-language users. For instance, you have various notifications for users, and you want to notify them after some actions. With that method, you can retrieve needed custom labels in that particular user’s language. That’s amazing.

5. Apex Publish Callbacks

With this generally available feature you can get the final result of an EventBus.publish call through an Apex publish callback that you implement. After you receive the final publish result, you can decide what action to take, such as attempting to republish failed events. 

Use EventBus.EventPublishFailureCallback to track failed event publishes:

public class FailureCallback implements EventBus.EventPublishFailureCallback {
      
   public void onFailure(EventBus.FailureResult result) {
       // Your implementation.
       // Get event UUIDs from the result
       List<String> eventUuids = result.getEventUuids();
       // ...
   }        
}

 

Use EventBus.EventPublishSuccessCallback interface to track successful event publishes:

public class SuccessCallback implements EventBus.EventPublishSuccessCallback {
      
   public void onSuccess(EventBus.SuccessResult result) {
       // Your implementation.
       // Get event UUIDs from the result
       List<String> eventUuids = result.getEventUuids();
       // ...
   }        
}

I personally like this tracking functionality because it gives you better control of the async Apex. It is always good to have the ability to attach callbacks to async actions, isn’t it?

Final thoughts

Here are Salesforce Summer ’23 release updates for developers that have caught my eye. Please feel free to share your favorite features in the comments!