Skip links

Top 5 Salesforce Summer ’24 Features for Developers

Here are 5 amazing Summer ’24 release features according to the ENWAY team. Discover how these new tools can streamline your workflow, improve performance, and handle high-volume jobs more efficiently.

Five-Level Parent-to-Child Relationship SOQL Queries in Apex

Starting from the Summer ’24 release, Apex allows SOQL relationship queries to go up to five levels deep in parent-child records.

But remember that each subquery in these relationships counts towards the total number of aggregate queries in a SOQL statement.

Use the Limits.getAggregateQueries() method to track the number of aggregate queries in a statement. The Limits.getLimitAggregateQueries() method returns 300, which is the maximum number of aggregate queries allowed.

List<Account> accts = 
[SELECT Name,
    (SELECT LastName,
        (SELECT AssetLevel,
            (SELECT Description,
                (SELECT LineItemNumber FROM WorkOrderLineItems)    
            FROM WorkOrders)    
        FROM Assets)    
    FROM Contacts)    
FROM Account];

This query starts with the Account root and includes child relationships down to five levels.

Apex Cursors for Efficient SOQL Query Processing

Another hot feature has been in Beta since the Summer ’24 release. Now developers can use Apex cursors to process SOQL query results in chunks, which can be handled within a single transaction. Cursors are an alternative to batch Apex and can be used in a chain of queueable Apex jobs. So, you can move through query results in parts, forward and backward, which is useful for package devs and advanced devs handling large-volume jobs.

Apex cursors are stateless and generate results based on the offset specified in the Cursor.fetch(integer position, integer count) method.

You must track the offsets or positions within your processing scenario.

A cursor is created when a SOQL query is executed using Database.getCursor() or Database.getCursorWithBinds(). When the Cursor.fetch(integer position, integer count) method is called, it returns the specified rows from the cursor. Each cursor can handle up to 50 million rows, whether the operation is synchronous or asynchronous. To get the number of rows returned, use Cursor.getNumRecords().

Apex cursors can throw two new exceptions: System.FatalCursorException and System.TransientCursorException. Transactions that fail with System.TransientCursorException can be retried. Apex cursors have the same expiration limits as API Query cursors.

Here are the governor limits for Apex cursors:

  • Maximum rows per cursor: 50 million
  • Maximum fetch calls per transaction: 10
  • Maximum cursors per day: 10,000
  • Maximum rows per day (aggregate): 100 million
public class QueryChunkingQueuable implements Queueable {
    private Database.Cursor locator;
    private integer position;

    public QueryChunkingQueuable() {
        locator = Database.getCursor
                  ('SELECT Id FROM Contact WHERE LastActivityDate = LAST_N_DAYS:400');
        position = 0;
    }

    public void execute(QueueableContext ctx) {
        List<Contact> scope = locator.fetch(position, 200);
        position += scope.size();
        // do something, like archive or delete the scope list records
        if(position < locator.getNumRecords()) {
            // process the next chunk
            System.enqueueJob(this);
        }
    }
}

This is how to use Apex cursors to process query results in chunks.

New Components Prepared for Native Shadow DOM

Salesforce is updating base Lightning components to use native shadow DOM, enhancing performance and aligning with Web Components standards. These changes will alter the internal DOM structure.

In Summer ’24, the following components will be adapted for native shadow DOM:

  • lightning-button
  • lightning-file-upload
  • lightning-formatted-name
  • lightning-formatted-number
  • lightning-navigation
  • lightning-progress-bar
  • lightning-progress-ring
  • lightning-select
  • lightning-textarea

Please be aware that If your tests rely on the current internal DOM structure, you need to rewrite them as soon as possible.

Use Third-Party Web Components in LWC (Beta)

Third-party web components in LWC, still in beta, often need an open shadow root to use web APIs like appendChild and adoptedStyleSheets. Open mode now allows access to the shadowRoot object. They can add HTML tags like div and style or share stylesheets with a shadow root.

To create a shadow root, custom elements use the attachShadow() method in the constructor. Previously, Lightning Web Security automatically switched open mode to closed mode, blocking JavaScript access to the shadow DOM tree and making shadowRoot return null.

connectedCallback() {
    let shadow = this.attachShadow({ mode: 'open' });

    let span = document.createElement("span");
    span.textContent = "I'm in the shadow DOM";

    shadow.appendChild(span);
}

In perspective, this will add numerous opportunities to Salesforce development through easy usage of third-party libraries. 

More Info in Apex Exception Emails

Here is a small yet great update. When your Apex code runs into unhandled exceptions, the exception emails now include the org name, user name, and My Domain name where the exception occurred.

Previously, the emails only included the Apex stack trace, exception message, and the customer’s org and user ID. With this enhancement, developers will be able to solve errors quickly. 

Final Thoughts

Here are the hottest Summer ’24 updates that simplify your development workflow. Also, read our article about the top Summer ’24 features for admins.