The sizzling Salesforce Summer ’24 release is just around the corner! Like sunshine breaking through the clouds, the highly-anticipated release notes are here to illuminate your day. This summery burst of features brings a wave of exciting new additions!
Discover all the details to get ready for your instance’s upgrade, and find your release window here. But for now, let’s dive into the heart of this blooming landscape and explore the most captivating features and updates – crafted specifically for developers – in the Salesforce Summer ‘24 release.
1. Evaluate Dynamic Formulas in Apex (Beta)
In Apex, there’s exciting news: Dynamic formulas can now handle SObjects! With the introduction of the `Formula.builder()` method, you can easily create a FormulaBuilder instance to tailor your formulas as needed.
What’s even better? You can use the `getReferencedFields()` method to fetch a list of field names referenced within a formula. This handy feature streamlines your workflow by providing quick access to the fields your formula interacts with.
Here’s a bonus: While formula evaluation in Apex is constrained by a character limit, there’s no need to worry about hitting the compile size limit. This flexibility allows you to craft complex formulas without being hindered by compile size restrictions.
Let’s take a look at how this might work. Let’s say you want to calculate a potential discount for an Opportunity based on the Opportunity amount and a user-specified discount percentage stored on a custom field.
Opportunity opp = [SELECT Id, Amount, Discount_Percentage__c FROM Opportunity WHERE Id = :someOppId];
// Construct the dynamic formula using Formula.builder()
FormulaBuilder fb = new Formula.builder();
Formula dynamicDiscountFormula = fb
.discount(opp.Amount, opp.Discount_Percentage__c) // Hypothetical 'discount' function
.build();
// Evaluate the formula
Object result = dynamicDiscountFormula.evaluateWith(opp);
// Cast the result (likely a Decimal) and use it as needed
Decimal calculatedDiscount = (Decimal) result;
System.debug('Calculated Discount: ' + calculatedDiscount);
Here is what the above is doing:
- Fetching the Opportunity: We query for the relevant Opportunity record.
- Constructing the Formula:
- We create a FormulaBuilder instance.
- We assume a hypothetical discount function within the FormulaBuilder to calculate the discount based on the amount and percentage (you would likely tailor this to your specific calculation).
- The build() method finalizes the formula.
- Evaluating the Formula:
- The evaluateWith(opp) method executes the formula in the context of the Opportunity, substituting field values.
- Handling the Result:
- We cast the result to a Decimal for further usage.
2. New and Updated Items in Apex
As usual, there are plenty of new and updated Apex items. First up is the Auth namespace which introduces several enhancements, including new classes, methods, and changes to existing ones.
New Classes:
- ExternalClientAppOAuthHandler: This class extends the capabilities of managing external client apps. Key methods include authorize, customAttributes, and refresh for user authorization, attribute setting, and configuring token refresh.
- Auth.HttpCalloutMockUtil: A new utility class facilitating mock HTTP callouts, promoting enhanced test coverage.
New or Changed Methods in Existing Classes:
- Auth.JWT Class: Several methods like getValidityLength, setValidityLength, getNbfClockSkew, and setNbfClockSkew now handle exceptions differently, throwing a NoAccess exception for JWTs generated using Auth.JWTUtil.
- Auth.JWT Class: The getAdditionalClaims method now returns additional claims for JWTs generated using Auth.JWTUtil, with claims formatted as inner lists converted to JSON strings for easier conversion into maps.
In the ConnectApi namespace (also known as Connect in Apex), new classes, methods, and enums are introduced, offering expanded functionalities for REST API resource actions.
In the DataSource namespace, updates focus on mapping external data types to Salesforce external objects via the Apex Connector Framework. New methods like currency, date, email, percent, and phone in the Column class enable the creation of new columns on a DataSource.Table.
Under the System namespace, notable additions include Apex cursors for traversing large result sets, instantiation of FormulaBuilder, improved error handling for non-platform event sObjects, and new exceptions for cursor management.
In the FormulaEval namespace (Beta), enhancements include new methods for retrieving referenced field names in formulas and setting context types for formula evaluation.
Lastly, the Enablement namespace (Developer Preview) introduces classes and methods for creating custom items in Enablement programs. Key classes like EnblProgramTaskDefSubCategoryType, LearningItemType, and LearningItemTypeHandler facilitate defining exercise and learning item types, along with providing metadata information for custom learning item types.
3. Updates to SOQL
As with Apex, SOQL has also received some love with plenty of enhancements in the upcoming release that may impact existing code reliant on older errors and functionality.
Changed Error Codes:
The error code `MALFORMED_QUERY` now replaces `D_QUERY_FIILTER_OPERATOR`.
Changed Functionality:
Negative currency values are now permissible in queries, such as:
SELECT Name FROM Invoice__c WHERE Balance__c < USD-500
Changed Error Messages:
Below are examples illustrating how error messages have evolved:
Invalid SOQL queries:
SELECT Id FROM Account USING everything
- Old: unexpected token: ‘<EOF>’
- New: unexpected token: ‘everything’
Quotes surrounding an unexpected token:
ELECT annualrevenue , parentid FROM Account
WHERE (isDeleted = false AND NumberOfEmployees != 100)
OR (isDeleted = false AND Site = '999')
AND ParentId = '000000000000000' LIMIT 50000 OFFSET 0
- Old: unexpected token: AND
- New: unexpected token: ‘AND’
Using NULL literals in WHERE statements:
SELECT Id, Name, Country__c, State__c, City__c, PAN_Number__c
FROM Account WHERE PAN_Number__c like NULL AND Name LIKE '%a%'
- Old: invalid operator
- New: unexpected token: ‘OR’
More than two nested functions:
SELECT convertCurrency(calendar_year(convertTimezone(lastmodifieddate))) FROM account
- Old: expecting a right parentheses, found ‘(’
- New: unexpected token: ‘(’
Invalid datetime literals:
SELECT Id FROM Account WHERE SystemModstamp > 2020-12-12t12:12:00-25:00
- Old: line 1:67 mismatched character ‘5’ expecting set ‘0’..’3′
- New: Invalid datetime: 2020-12-12t12:12:00-25:00
Using “WITH SECURITY_ENFORCED” without a proper Apex context setup:
SELECT Id FROM Account WITH SECURITY_ENFORCED
- Old: SECURITY_ENFORCED not allowed in this context
- New: rule soqlWithIdentifierClause failed predicate: {this.helper.allowApexSyntax() && this.helper.hasApexContext()}
Be mindful that running SOQL queries against DMOs may consume Data Services credits from your Data Cloud subscription. Ensure caution when utilizing features like ‘FOR’ loops, query locators, recursion, or any mechanism resulting in multiple queries to Data Cloud. For comprehensive information on usage billing, refer to the Data Cloud Billable Usage Types documentation.
4. Data Cloud Objects – Now With SOQL!
Static SOQL is now an available option for querying Data Cloud data model objects (DMOs), providing a more direct alternative to using dynamic SOQL or ConnectAPI. This enhancement allows for more efficient and straightforward querying of DMOs. Additionally, starting from API version 61.0, SOQL queries using Apex `Database.QueryLocator` or within `FOR` loops are supported.
Prior to version 61.0, only the first 201 records were returned in such queries. Batch Apex is currently restricted from using QueryLocators with DMOs but is supported when using Iterable. This change applies across all Salesforce editions.
Here’s an example demonstrating the usage of static SOQL with the `UnifiedIndividual__dlm` Data Cloud object:
// Static SOQL example
List<UnifiedIndividual__dlm> unifiedIndividuals = [
SELECT
Id,
ssot__FirstName__c,
ssot__LastName__c,
ssot__Email__c,
ssot__SkyMilesBalance__c,
ssot__MedallionStatus__c
FROM UnifiedIndividual__dlm
WHERE ssot__CompanyId__c = :companyId
];
However, it’s crucial to note that running SOQL queries against DMOs can consume Data Services credits from your Data Cloud subscription. Ensure caution when utilizing features like `FOR` loops, query locators, recursion, or any mechanism resulting in multiple queries to Data Cloud. For comprehensive information on usage billing, refer to the Data Cloud Billable Usage Types documentation.
5. Scratch Org Snapshots for Efficient Configuration in Salesforce – Now GA
We highlighted this feature going into beta in the Spring ‘24 release. Well, that beta seemed to go pretty well as this feature is now being made generally available!
Scratch Org Snapshots allow users to capture a snapshot of a scratch org’s configuration at a specific moment in time. This snapshot can then be used to replicate the same configuration in other scratch orgs, streamlining the process of reproducing specific setups.
Scratch Org Snapshots are available in both Lightning Experience and Salesforce Classic, across Developer, Enterprise, Performance, and Unlimited editions. To access this feature, the Dev Hub org needs to be upgraded to the Spring ’24 release.
This feature simplifies the traditionally manual and time-consuming process of setting up scratch orgs with project dependencies. Users can activate Scratch Org Snapshots in their Dev Hub org, and Salesforce CLI commands such as “org create snapshot” and “org list snapshot” can be used to manage and create snapshots.
Ultimately, Scratch Org Snapshots boost efficiency by facilitating the rapid replication of scratch orgs with specific project dependencies, reducing the need for repetitive manual configurations.
6. Run Flows in Bot User Context – Enforced
With this update turned on, when a bot starts a process, it uses the user profile and permission sets linked to the bot to decide what data it can access and change.
Before this update, processes started by a bot worked in system mode, giving them permission to access and change any data.
Now, processes are started by a bot work in user mode. When a bot starts a process, the permissions linked to the bot and any sharing rules determine what data the process can access and change.
For instance, let’s say the bot triggers the Update Account Type process:
POST /v54.0/actions/custom/flow/Update_Account_Type
This update enhances security in Salesforce by preventing bots from accidentally creating or changing records they shouldn’t.
7. Allow Only Trusted Cross-Org Redirections – Enforced
To safeguard your users and network, ensure that you include the specific Salesforce org URLs you trust in the Trusted URLs for Redirects allowlist. Without being on this list, users won’t be able to navigate to a different Salesforce org, including its publicly accessible pages and content, from your org.
Any redirections to other Salesforce orgs will be restricted unless the URL is listed in the Trusted URLs for Redirects allowlist. Essentially, users won’t be able to reach a different Salesforce org’s content from your org unless the URL is deemed trustworthy.
This measure aims to protect users from potential security threats, permitting links, actions, or processes to direct users to another Salesforce org only if the target URL is trusted.
This change specifically affects situations where users are directed to a different Salesforce org, such as when clicking a link to an Experience Cloud site hosted in another Salesforce org. Once this update is enforced, such redirections will be permanently blocked.
The following types of URLs are most commonly impacted:
- Hard-coded links leading to a different org, like a link pointing to a production URL in a sandbox environment.
- Processes that guide users to another org, such as a workflow in production directing users to a sandbox to perform a task.
- Links redirecting users to another production org, especially relevant if you manage multiple production orgs.
Notably, this change doesn’t affect access to URLs within the same org with different domains, such as links from a Lightning page to a file. Users will always be able to access URLs within the org where they are logged in.
8. Enable EmailSimple Invocable Action to Respect Organization-Wide Profile Settings
With this update activated, the EmailSimple invocable action follows the email address profile settings set at the organization level.
Once enabled, any usage of the EmailSimple invocable action will comply with the organization-wide email address profile settings.
Previously ignored, the profile restrictions within your organization-wide email address settings now take effect.
Any features utilizing EmailSimple for organization-wide email addresses will be affected if they’re executed within a user context and the user’s profile doesn’t align.
9. Lightning Component Updates
Updates to Lightning Components are aplenty in this release. Below are some of these updates, along with some recommendations on how you may want to address them:
Lightning Web Components (LWC)
- Accessibility Enhancements: Many LWC components (combobox, datatable, helptext, input, progress-indicator, etc.) have improved keyboard navigation, error handling, assistive text, and ARIA attributes for a more inclusive user experience.
- New Attributes: Gain more control over component behavior with new attributes like:
- aria-describedby and aria-labelledby (select, textarea) for better accessibility
- date-access-key and time-access-key (input type=”datetime”) for keyboard shortcuts
- show-compact-address, subpremise, subpremise-label, and subpremise-placeholder (input-address) for refined address form layouts.
- Dynamic Data Loading (lightning-tree): Improve the performance of large trees by loading data dynamically as tree nodes are expanded.
- Module Updates:
- lightning/analyticsWaveApi: New functions to manage CRM Analytics folders.
- lightning/platformUtilityBarApi (Beta): Control utility bar elements programmatically.
- lightning/platformWorkspaceApi: Enhanced compatibility and no longer requires Lightning Web Security pre-activation.
- experience/mobilePublisherConfigApi (Beta): New wire adapter to manage mobile publisher navigation.
Aura Components
- lightning:InputAddress: Offers more flexible address input formats with new attributes (showCompactAddress, subpremise, subpremiseLabel, and subpremisePlaceholder).
Based on these updates, we recommend developers review their custom Lightning Web Components (LWC) and Aura components to assess how they can leverage the accessibility changes and new attributes introduced in recent updates. For applications dealing with large tree structures, adopting the lightning-tree component with dynamic data loading capabilities can significantly enhance performance and user experience.
Additionally, exploring the latest module updates for Lightning Web Components (LWC) offers opportunities to extend functionality and improve development efficiency by incorporating new features and enhancements into applications.
10. Streaming API Retirement
If you are using Streaming API versions 23.0 through 36.0, this is an important update. These API versions are scheduled for retirement in the Winter ’25 release. These versions are now deprecated and will no longer receive official support.
It’s essential to recognize the significance of this update for several reasons. Firstly, sticking with older versions means missing out on the latest enhancements and bug fixes, which could impact the performance and stability of your application.
Secondly, as Salesforce continues to evolve, these legacy versions may encounter compatibility issues, potentially resulting in unexpected behavior or integration breakdowns. Therefore, action is required to ensure the continued efficiency and reliability of your Salesforce environment.
If your applications are currently dependent on any of the retiring Streaming API versions, it’s imperative to promptly upgrade to a supported version. This urgency stems from three key factors:
- Newer API versions (37.0 and above) provide improved features, bug fixes, and overall reliability, contributing to enhanced stability and performance.
- Ensuring your integrations remain functional is crucial for long-term compatibility, safeguarding against disruptions as Salesforce progresses.
- By transitioning to Durable Streaming, introduced in version 37.0, you can capitalize on advanced event replay capabilities and enhanced fault tolerance, further fortifying your system’s resilience.
Summary
And there you have it – our overview of the most scorching Salesforce Summer ’24 release features, tailored especially for developers.
Have you come across any other fresh new additions? Share your discoveries in the comments!