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
tulasiram chtulasiram ch 

please explain me what will be exists in below

in 3rd line created list of ID's List<ID> ids, then in 5th line [SELECT Name FROM Account WHERE ID in :ids];  .i think parameter ids has null values then how can we query like ID IN :ids...please explain me what will exists in the parameter of 'ids' in 3rd line...
public class AccountQueryAction {
@InvocableMethod(label='Get Account Names' description='Returns the list of account names corresponding to the specified account IDs.')
public static List<String> getAccountNames(List<ID> ids) {
List<String> accountNames = new List<String>();
List<Account> accounts = [SELECT Name FROM Account WHERE Id in :ids];
for (Account account : accounts) {
return accountNames;
You need to capture the values of ids before use used that in query

Try below code
public static List<String> getAccountName(List<ID> ids)
set<id> setid=new set<id>();
for(Account acc:ids)

List<Account> accounts=[SELECT Name FROM Account WHERE Id in:setid];
If you have any concerns let me know
tulasiram chtulasiram ch
Thanks vignesh for your reply. but that code was given by salesforce pdf document, i need explanation for that statement please what will exists in parameter ids
Vinuthh SVinuthh S
Hi Tulasiram

In the line no.3 add all the Account id in one list,after that line no.5 quered all the account records with the list of Ids.

This is used to overcome the Governor Limits in Salesforce.If you use the query inside the for loop you will get

Too many SOQL error  and CPU time limit exception error.To overcome this errors used the above code.

Vinuthh S
tulasiram chtulasiram ch
public static List<String> getAccountNames(List<ID> ids) 
Vinuthh thanks for reply, how can that statment knew that only Account ids need to be stored in parameter named as ids