function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PlainviewPlainview 

Need to make a query selective.

I am new to Apex and need to add an index filter.

The query in question:

"List<Account> leadAccountIds=Select Id, OwnerId, Name FROM Account WHERE Name IN: companies;"

Seeking some syntax advice.

Thanks!
 
RamuRamu (Salesforce Developers) 
the below article might help

https://help.salesforce.com/apex/HTViewSolution?urlname=How-can-I-make-my-SOQL-query-selective-And-the-process-to-determine-the-fields-that-can-be-custom-indexed&language=en_US
Sumitkumar_ShingaviSumitkumar_Shingavi
It should be
List<Account> lAccountIds = [Select Id, OwnerId, Name FROM Account WHERE Name IN :companies];
and "companies" might be
Set<String> companies = new Set<String>();

 
Vikash TiwaryVikash Tiwary
List<Account> leadAccountIds = [Select Id, OwnerId, Name FROM Account WHERE Name IN: companies];

Thanks