Developers

5 Tips For Every Salesforce Developer

By Saifullah Saifi

As a Salesforce Developer, it is imperative to stay up to date with each new Salesforce release. Three times a year, Salesforce releases updates, features, and sometimes even a new language or framework. With each release, something that wasn’t previously possible becomes possible.

In this post, I will share 5 features every Developer needs to make use of.

1. Sharing rule needed for All Classes

The “with sharing” keyword is used to enforce user access and permissions for Visualforce page controllers, trigger helpers, Aura Component based Apex Classes, and Lightning Web Component (LWC) based Apex classes.

Apex classes generally run in system mode. Consequently, the current user’s credentials aren’t used to execute Apex logic, and the user’s permissions and field-level security aren’t automatically applied.

Check out the example below for AuraEnabled Class:

2. Use the Safe Navigation Operator

As Developers, we often worry about Null pointer exceptions, but this can be resolved by Safe Navigation Operator (?).

Whereas before we were writing at least 2 or 3 lines of code to check null exceptions, now it is doable in a single line.

3. Use Salesforce Dynamic Forms before creating a custom detail page UI

Salesforce Dynamic Forms is not just a feature for Admins! It can also help Salesforce Developers avoid redundant coding.

The premise of Dynamic Forms is to create user-centric, intuitive page layouts that display the right information at the right time. Over time, the page layout, or the “Details” section in Lightning pages, can become congested with fields. These fields may well be necessary but not all the time or to all users. The closest resolution we’ve had is to create multiple page layouts and different profiles, which is labor and config intensive.

With Dynamic Forms you’ll be able to:

  • Place fields anywhere on the layout without needing to add them to the traditional page layout (“Details” tab)
  • Use visibility rules to make fields and components appear and disappear based on the criteria you choose
  • Do away with multiple-page layouts
  • Improve page load times

You can either create brand new pages or migrate your existing Lightning Pages using the prompt shown below:

Once you’ve migrated or created a new Lightning record page, you will see the option to add a “Field Section” component which will then enable you to add fields directly to the Lightning record page.

4. Install Apex Recipe and LWC Recipe in your Developer Org to learn Best Practices

Apex Recipes is a library of concise, meaningful examples of code for common use cases following best practices”.

Source: Introducing Apex Recipes

Examples include how to write great triggers, how to make a callout, and how to create an Async class.

Similarly, LWC Recipes will provide code and examples for Lightning Web Components, such as how to learn to connect LWC with Apex, how to create a form, how to combine 2 components, and so on.

Here is the list of all components and examples that LWC Recipe will provide for you:

5. Enforce Field-Level Security in Apex

Salesforce had System.AccessType class to check CRUD access in Apex and have recently added UPSERTABLE enum method in this class. Now, Salesforce has released the stripInaccessible method to enforce field and object level checks for both insert and update.

stripInaccessible can be used for the following:
To strip the fields that the current user can’t access from query and subquery results.
To remove inaccessible fields from sObjects before a DML operation to avoid exceptions.
To sanitize sObjects that have been deserialized from an untrusted source.

For example:

Source: Salesforce Developer guide

Summary

With every release, Salesforce gives you new features and methods to explore. Developers must proactively keep up to date with all of these exciting changes to provide the best possible service to their customers, following best practices and utilizing Salesforce features to get the greatest return on investment.

The Author

Saifullah Saifi

Sr Salesforce Developer, Author of "Cloud Computing using Salesforce"

Comments:

    Jehanzeb
    January 06, 2021 6:50 pm
    Very informative. Thank Saifullah bhai.
    pallavi
    January 09, 2021 12:21 pm
    This is a very nice one and gives in-depth information. I am really happy with the quality and presentation of the article. I’d really like to appreciate the efforts you get with writing this post. Thanks for sharing. https://www.sevenmentor.com/salesforce-training-in-pune.php
    Rubix
    April 14, 2021 3:21 pm
    It has an impressive range of content for patients.I just loved your way of presentation. I enjoyed reading this .Thanks for sharing and keep writing. It is good to read blogs like this. Rubix Research
    Vigneshwar
    May 06, 2021 9:53 am
    Thanks for sharing this valuable information with our vision. You have posted a trust worthy blog keep sharing.
    Christine Marshall
    May 06, 2021 10:33 am
    Thanks for reading!

Leave a Reply