Salesforce Summer 23 Release | My Top 5 Apex Features

Salesforce Summer 23 Release | My Top 5 Apex Features

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.

Comments

Difference Between Named Credential and External Credential in Salesforce

Difference Between Named Credential and External Credential in Salesforce

Sudipta Deb

Sudipta Deb

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

In today's data-driven business landscape, seamless integration of various applications and services is paramount to streamline processes and improve efficiency. Salesforce, as a leading CRM platform, is no stranger to this requirement. Among the plethora of features it offers, Named and External Credentials are two key components that facilitate secure and efficient communication between Salesforce and external systems.

In this blog post, I will focus on the differences between Named and External Credentials in Salesforce, exploring their key features.

What Is Named Credential?

Named Credentials are a way to store and manage authentication information required to call external services, APIs, or other systems from Salesforce. Named Credentials simplify the process of connecting to external services by managing authentication information in a single place, enabling secure storage and reuse of these credentials across multiple integrations.

Key Features of Named Credentials

  • Secure storage of authentication information like usernames, passwords, tokens, or certificates.
  • Support for various authentication protocols like OAuth 2.0, Basic Authentication, or JWT Bearer.
  • Ability to make callouts to external systems using Apex or declarative tools without hardcoding credentials.

What Is External Credential?

External Credentials, on the other hand, are specifically designed to store and manage the authentication information for external identity providers, which can be used in Salesforce for setting up Single Sign-On (SSO) or Social Sign-On. External Credentials enable a user to log into Salesforce using their credentials from an external identity provider, like Google, Facebook, or any SAML-based service.

Key Features of External Credentials

  • Secure storage of authentication information for external identity providers.
  • Support for different authentication protocols like OAuth 2.0, OpenID Connect, or SAML.
  • Enable Single Sign-On (SSO) or Social Sign-On for Salesforce users by delegating authentication to external identity providers.

New - How To Add Named Credentials To Permission Set Using Principals

Read this blog post to understand the new way (coming with Summer 23 release) to add Named Credentials to Permission Set using Principals.

Summer 23 Release | How To Add Named Credentials To Permission Set Using Principals

Watch the Youtube video below 

Conclusion

In summary, Named Credentials are used for securely managing authentication information for external services or APIs, while External Credentials are used for securely managing authentication information for external identity providers to enable SSO or Social Sign-On in Salesforce.

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.

Comments

Summer 23 Release | New Flow Feature | HTTP Post Call From Salesforce Flow

Summer 23 Release | New Flow Feature | HTTP Post Call From Salesforce Flow

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 a very powerful feature that is coming along with Summer 23 release. With Summer 23 release, you can call HTTP Post methods directly from Salesforce Flow. Previous release, Salesforce introduced the power of calling HTTP Get methods from Salesforce Flow. Here is the youtube video, where I have explained the configuration - https://youtu.be/n-vHAqr6KiI

Read this blog post or watch the video below to understand how to call HTTP Post methods from Salesforce Flow.

Prerequisite

The first thing that you need to configure is Named Credentials. I have a dedicated blog post and youtube video where I have shown the new process of creating named credentials/external credentials that is coming along with the Summer 23 release.

Blog: https://sudipta-deb.in/2023/04/summer-23-release-how-to-add-named-credentials-to-permission-set-using-principals.html

Youtube: https://youtu.be/53q3I-bJobk

 

API Being Used

For this demo, I will be using the Post Call from the website - https://restful-api.dev/

Step 1 - Create The Flow

Let's start with a Screen Flow and add the Action element. In the Filter By dropdown, select Type and then select External Service.

Here select the External Service Action from the available actions. In my case, I will select the action named as PostCallAction.

Step 2 - Configure The New Action

I will configure the action as below -

    • Label - externalPostCall

For the body, I will create a new Variable and the type of the variable will be "Apex-Defined Variable".

Step 3 - Create The Apex-Defined Variable

Here I will create the new Apex-Defined Variable with below parameters -

    • Resource Type - Variable
    • API Name - InputBody
    • Data Type - Apex-Defined
    • Apex Class - ExternalService__PostCall_PostCallAction_IN_body (This should correspond to the external service name)

Step 4 - Finish The Action Element

With the Apex-Defined variable configured, I will save the Action Element. Now what I need to do is assign the values to this Apex-Defined variable, which is basically the input to the HTTP Post Call.

Step 5 - Assign Values to Apex-Defined Variable

I will create one Assignment block just before the Action block. The reason is to assign input values as per the API documentation (https://restful-api.dev/).

Below is the screenshot of what my Assignment element looks like.

Debug The Flow

With everything configured, I can now debug the flow and test to ensure I am getting the expected result. Here is the screenshot of debug.

Conclusion

In conclusion, utilizing HTTP POST method calls from Salesforce Flows is a powerful technique that can significantly enhance your automation capabilities within the Salesforce ecosystem. By integrating external services and systems with Salesforce, you can create more robust, dynamic, and intelligent workflows that cater to a wide range of business scenarios.

Throughout this blog post, I have discussed the key aspects of implementing HTTP POST method calls from Salesforce Flows. I have shown how to configure and set up an external service using Named Credentials, create an HTTP Request object, and handle responses. Furthermore, I have touched upon best practices and considerations to ensure the security and efficiency of your integration.

As you explore the world of Salesforce Flows and HTTP POST method calls, remember to think creatively and strategically about how you can leverage these tools to streamline your business processes, reduce manual tasks, and improve overall productivity. Keep experimenting, learning, and pushing the boundaries of what you can accomplish with Salesforce Flows and HTTP POST method calls. Happy integrating!

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.

Comments