Sudipta Deb

Sudipta Deb

Founder of Technical Potpourri, Co-Founder of Shrey Tech, Enterprise Cloud Architect

Salesforce Release is the process by which Salesforce updates its software platform to add new features, enhancements, and bug fixes. Salesforce releases typically occur three times a year, in spring, summer, and winter, and are named after the season in which they are released.

Each release includes a set of new features and improvements to existing features, which are designed to help users get more out of the platform. Salesforce also provides detailed release notes that outline the changes in each release, along with documentation and training materials to help users understand and adopt the new features.

In today’s blog, I am going to share my top 5 Apex features.

Read this blog post or watch the video below to understand the new Apex features that are coming along with Summer 23 release.

Access Labels in Apex Dynamically

This change applies to Lightning Experience and Salesforce Classic in all editions. Now we will get two new methods to get a custom label, optionally specifying a language. This feature allows us to dynamically fetch custom label values and check if a translation exists for that label for a particular language.

Documentation: Click Here

public with sharing class CustomLabelFetch {
 public void fetch() { 
 /*  System.Label.get(namespace, label, language)
 Input:
 namespace - Required -  If namespace = null, it defaults to the package namespace. If namespace = empty string, it implies the org namespace. 
 label - Required - name of the custom label. 
 language - Optional - language. 
 Return:
 String - Custom Label Value
 */
 String salesforceRelease = System.Label.get('','SalesforceRelease');
 System.Debug('salesforceRelease: ' + salesforceRelease); 
 }
 public void fetchInGerman() { 
 /*  System.Label.translationExists(namespace, label, language)
 Input:
 namespace - Required -  If namespace = null, it defaults to the package namespace. If namespace = empty string, it implies the org namespace. 
 label - Required - name of the custom label. 
 language - Required - language. 
 Return:
 Boolean - True if Translation Exists, Otherwise False
 */
 if(System.Label.translationExists('','SalesforceRelease', 'de')){
 System.Debug('salesforceRelease in German: ' + System.Label.get('','SalesforceRelease','de'));
 }
 }
}

As you can see from the above example, inside the first method fetch(), I am using the method System.Label.get() to find the custom label value.

But in the second method i.e. fetchInGerman(), first I am using the method System.Label.translationExists()  to find out whether there is any translation available for the custom label in German language. And if available, then use the method System.Label.get() to find the German translated value of the custom label. This time I am passing the third parameter ‘de’ which is German language code.

Configure Stack Depth of Chained Queueable Jobs (Beta)

This change applies to Lightning Experience and Salesforce Classic in all editions. Currently, this feature is in Beta service. Customers can opt-in for this service and try it in their own sandbox. The default stack depth limit in Developer and Trial Edition orgs is 5, but now after Summer 23 release, we will have the option to override the limit and set our own stack depth limit.

We can now enqueue jobs by using the new System.enqueueJob() overload method. This overload method will give us the optional AsyncObjects parameter where we can specify the maximum stack depth and the minimum queue delay.

Here are the methods available –

  • getCurrentQueueableStackDepth()
  • getMaximumQueueableStackDepth()
  • getMinimumQueueableDelayInMinutes()
  • hasMaxStackDepth()

Documentation: Click Here

Use the Iterable Interface with Set Type

This change applies to Lightning Experience and Salesforce Classic in all editions. Set class now implements the Iterable interface, so you can directly iterate over sets. All the powerful String methods can now be applied on set.

Documentation: Click Here

public with sharing class StringHelperClass {
 public void checkNewFeature(){
 Set<String> letters = new Set<String>{'a','b','c','d'};
 System.debug(String.join(letters, '...'));
 } 
}

Manage DML Exceptions in User-Mode Database Operations

This change applies to Lightning Experience and Salesforce Classic in all editions. Before the Summer 23 release, user-mode DML operations were generating a SecurityExcpetion, but after this release, it will generate the correct DMLException.

Documentation: Click Here

If you want to understand How to Secure Apex Code With User Mode Database Operations, please watch my youtube video below

Query Five Levels of Parent-To-Child Relationships in SOQL

This change applies to Lightning Experience and Salesforce Classic in all editions. SOQL now supports relationship queries that can traverse up to five levels of parent-child records. The important thing that you need to understand is that this feature is limited to SOQL queries via the REST and SOAP query calls on standard and custom objects.

Documentation: Click Here

Below is the query string which I have used in REST context to fetch five levels of data.

Query String –

/services/data/v58.0/query?q=SELECT+Name,+(SELECT+LastName,+(SELECT+AssetLevel,+(SELECT+Description,+(SELECT+LineItemNumber+FROM+WorkOrderLineItems)+FROM+WorkOrders)+FROM+Assets)+FROM+Contacts)+FROM+Account

Conclusion

In conclusion, the Salesforce Summer ’23 Release has truly outdone itself, introducing remarkable Apex features that are poised to redefine how developers engage with the Salesforce platform.

Salesforce’s commitment to innovation and continuous enhancement is unquestionably evidenced in these new features. They showcase the platform’s dedication to empowering developers with the tools necessary to build robust, scalable, and efficient applications. There is no doubt that these features will contribute to the creation of more dynamic, integrated, and efficient Salesforce environments.

As we move forward, it’s exciting to see how these advancements will shape the future of Salesforce development and what the platform has in store for us in its upcoming releases. We are indeed in an era of unceasing technological innovation, and Salesforce is clearly at the forefront, driving this change.

Remember, the effectiveness of these features lies in their implementation. So, as you embrace these new features, make sure to fully explore each one’s potential to maximize their benefits and further streamline your Salesforce development efforts.

Disclaimer

This article is not endorsed by Salesforce, Google, or any other company in any way. I shared my knowledge on this topic in this blog post. Please always refer to Official Documentation for the latest information.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *