Dynamically Pass Bind Variables to a SOQL Query - salesforce release'23
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.
Where: This change applies to Lightning Experience and Salesforce Classic in Enterprise, Performance, Unlimited, and Developer editions.
How: 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.
Comments
Post a Comment