Apex

#TDX23 – Apex Patterns & Best Practices

#1MinuteTip #TDX23 Here is the link to download the PDF on “Apex Patterns and Best Practices in 2023” presented in TrailblazerDX 2023. These best practices have been divided into 5 categories that includes:

  1. Security Best Practices
  2. Performance Best Practices
  3. Designing Apex for Scale
  4. Writing Reusable Apex Code
  5. Writing Maintainable Apex Code
Salesforce Apex Patterns & Best Practices

References & Useful URLs

#SalesforceSpring23 – Secure Apex Code with User Mode Database Operations

#1MinuteTip #SalesforceSpring23 The new Database and Search methods support an accessLevel parameter that lets you run database and search operations in user mode instead of in the default system mode.

Apex code runs in system mode by default, which means that it runs with substantially elevated permissions over the user running the code. To enhance the security context of Apex, you can specify user mode access for database operations. Field-level security (FLS) and object permissions of the running user are respected in user mode and it always applies sharing rules. In system mode, the class sharing keywords control the sharing rules.

Product Area: Development -> Apex

User Mode Database Operation in Apex Code

References & Useful URLs

  • For Related Spring ’23 Release Note Article – Click Here

Want to Receive these Tips in your Inbox?

Finding it overwhelming to keep pace with Salesforce’s new release features? Try our “1 Day 1 Tip 1 Minute” emails, where you are going to get 1 tip every day that won’t take more than a minute to read. To find out more and subscribe please click here.

#SalesforceSpring23 – Dynamically Pass Bind Variables to a SOQL Query

#1MinuteTip #SalesforceSpring23 With the new Database.queryWithBinds, Database.getQueryLocatorWithBinds, and Database.countQueryWithBinds methods, the bind variables in the query are resolved from a Map parameter directly with a key rather than from Apex code variables. As a result, it’s not necessary for the variables to be in scope when the query is executed.

In this example, the SOQL query uses a bind variable for an Account name. Its value (Acme Corporation) is passed in using the acctBinds Map.

Product area: Development – Apex

Pass Bind Variables to a SOQL Query

References & Useful URLs

  • For Related Spring ’23 Release Note Article – Click here
Scroll to Top
Introducing All Access Pass