#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

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
Introducing All Access Pass