You need to sign in to do that
Don't have an account?

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) {
accountNames.add(account.Name);
}
return accountNames;
}
}
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) {
accountNames.add(account.Name);
}
return accountNames;
}
}
Try below code If you have any concerns let me know
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.
Thanks
Vinuthh S
Vinuthh thanks for reply, how can that statment knew that only Account ids need to be stored in parameter named as ids