Salesforce Winter ’21 Highlights for Developers

Share this article...

The Winter ‘21 release has arrived – what’s new for Salesforce developers? It can be difficult to comprehend the amount of work Salesforce puts into each release. Three times a year, every year, our ecosystem evolves to provide us with new tools, and sometimes new challenges!

For us Salesforce developers, the sheer number of fixes, changes, and additions can often become overwhelming when we’re busy with our day-to-day work. I’ve gone through the Salesforce release notes to bring these top Winter ’21 enhancements to your attention.

“Validity”

1. Lightning Components: Access to @AuraEnabled Methods by Profile

Many of us have built Aura and Lightning Web Components by now, and much of that logic may make use of @AuraEnabled Apex methods, which reside inside controller classes. As of Winter ’21, in order for a lightning component to successfully communicate with an Apex method, the user must have the appropriate Apex class enabled on their profile or a permission set.
Since this applies to all components, new and existing, this may require profile changes to maintain existing functionality.

Fortunately, it’s really easy to add class permissions! Just open up a profile or permission set, select the Apex Classes section, and add your controller class to the list. If you manage profiles and permission sets through managed packages, now is a great time to add those!

Read more about this change here.

2. Flows: Generic SObjects in Flow Components

It’s no secret that flows are my absolute favourite feature in Salesforce. As developers, we get to build re-useable components that declarative app builders can use in different contexts and with different logic. Naturally, many of us have been trying to create truly generic components that can work with any SObject a flow throws at us, and found that we aren’t able to do that… until now!

Flow components can now receive parameters with the SObject and SObject[] data types, allowing us to work with any object type in a single component.

Read more about this change here.

3. Flows: Custom Property Editors for Flow Components

Hitting yet another fan-favourite flow idea, developers can now build their own property inputs in LWC. If you’ve ever worked with standard components, you may have found yourself envying their ability to use fancy inputs like lookups, or picklists with dynamic options – well envy no more! This update effectively lets you build a whole new mini-component to serve as the input panel for your component.

This new feature only exists for flows for the time being, but I’m secretly hoping to see this migrate to regular Lightning pages in the near future.

Read more about this change here.

4. Apex: Safe Navigation Operator

You can’t have a discussion about Winter ’21 without someone bringing up the safe navigation operator. It’s cool! It’s amazing! But what is it, actually?
Pretend that we’re working on a piece of code that works with contacts. This code needs the email address of the user who owns the contact’s account. Assuming we have a query that fetches the information, we often find ourselves writing code like this:

String accountOwnerEmail = myContact.Account.Owner.Email;

A week later, an angry user claims the code crashes for contacts who do not have an account set. And true enough, to avoid a null pointer exception, our code becomes something more akin to this mess:

String accountOwnerEmail;
if (myContact != null &&
    myContact.Account != null &&
    myContact.Account.Owner != null) {
        accountOwnerEmail = myContact.Account.Owner.Email; 
}

Needless to say, one version of the code is much more readable and friendly than the other.

The safe navigation operator makes our code friendly again by introducing the ?. operator. When using this, if the value of the current pointer is null, then a null value will be returned. Using the regular dot operator would result in a null-pointer exception being thrown.

And now our code is clean again:

String accountOwnerEmail = myContact?.Account?.Owner?.Email;

Read more about this change here.

5. Apex: Custom Notifications from Apex Code

It may be just my experience, but it feels like users are loving custom notifications. I have been building processes upon processes, sending these notifications out for all types of scenarios – but could not yet integrate them into my code-based automation.

Now custom notifications are also available in Apex code!

Using the new Messaging.CustomNotification class, we can define and fire notifications to our heart’s content.

Read more about this change here.

6. API: New Composite Graph API for Complex Composite Requests

This is a game-changer for anyone working with the Salesforce API. The new Composite Graph API lets developers create complex requests, combining different operations which don’t have to be related to one another, into a single transaction. You can also define all-or-none behaviour, thereby not having to worry about rolling data back in the event that a multi-step operation fails in the middle!

This means we can now perform several unrelated actions in a single API call, and a single transaction. The potential efficiency gains for API-heavy implementations are very real, so it’s worth taking some time going through the wonderful tutorial on the Salesforce Developer Blog.

Read more about this change here.

7. LWC: Lightning Design System Styling Hooks

Those of us who have been building lightning components know of one very important rule: if you stick to SLDS, everything will be fine! While SLDS does provide us with a fantastic and uniform CSS framework, we are often asked to make tweaks. One common request that crosses my mailbox is the ability to change component colours to match the company’s brand – and that often means creating custom stylesheets which may or may not be compatible with future releases.

With styling hooks, we get a simple, futureproof mechanism to set various styling attributes on a component level. This is done by setting the value of CSS variables which are used throughout the Lightning Design System. All we have to do is use our component’s stylesheet to set new variable values on :host, for example:

:host {
--sds-c-button-brand-color-background: green;
}

And just like that, buttons with the brand modifier become green!

Read more about this change here.

8. Beta: Create Scratch Orgs Similar to Real Ones using Org Shapes

While many developers work perfectly well on sandboxes, Salesforce has been shifting its focus toward Scratch orgs. These short-lived development-oriented orgs are the best way to work seamlessly with version control tools, but their detachment from any real production org means that features that worked in development could fail on the live system.

To combat this problem, Salesforce just made it easy to create scratch orgs that are based on real ones. You essentially register this org’s shape with your dev hub, and can then create a scratch org with similar settings, limits, and licenses as the original.

This beta feature is not fully supported yet, but may still prove to be an essential tool in the developer arsenal!

Read more about this change here.

9. Communities: Community Site Guest User Sharing Model

If you aren’t aware yet of the changes made to the site guest user, then this is the final boarding call! We’ve been warned about it for months, had a preview of it only a few weeks ago, but now the site guest user restrictions are here to stay.

Effectively, the site guest user’s sharing model for all objects is now permanently set to private. This means that visitors cannot view records that the guest user itself does not own, or are otherwise shared with it using the new guest user sharing rule (and those only grant read-only access). Combined with the fact that all new records created in a community are now owned by a default user rather than the guest user, this could affect functionality across the board for public communities.

Read more about this change here.

Honourable Mention: Dynamic Forms

I can’t stress enough just how excited I am for Dynamic Forms. This now generally-available feature lets an administrator configure sections of a record page individually, in ways never before possible in the lightning app builder!

But why is this relevant for developers? Glad you asked!

As a developer, every line of code we write requires maintenance. The more we create, the more we support and the more technical debt we incur. Eventually, this cycle becomes impossible to maintain, and we go through refactoring phases. We can completely avoid this issue by using the myriad of tools the platform provides for us out of the box. If Dynamic Forms reduce the need for custom pages and components, then we as developers are the ones who benefit – as we have more time to spend on the things that really matter: building amazing stuff.

Read more about this change here.

Summary

The Winter ‘21 release brings a lot of good features to the table. While we should never rush to utilise features just because they’re new, we can definitely make use of these new tools when it comes to designing better, more future proof applications on the Salesforce platform.

Don’t relax just yet, because before you know it, we will find ourselves in the year 2021 with even more new features coming our way!

One thought on “Salesforce Winter ’21 Highlights for Developers

Leave a Reply