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

How do I call this class from Execute Anonymous Window ?
Hello,
Please help me, how do I call below class from the anonymous window. I am not finding a way to pass IDs as parameter.
I want pass record Ids of Account for example this 0010I00001hMhFIQA0.
___________________________
public class AccountClass {
public static void CountMyContacts(Set<ID> recordIds){
List<Account> accs = [Select Id, Name from Account Where Id IN :recordIds];
for (Account a : accs){
List<Contact> Cons = [Select Id, Name from Contact Where AccountId = :a.Id];
integer ConCount = Cons.size();
system.debug( Account.Name + 'account has' + ConCount + 'number of contacts');
}
}
}
Please help me, how do I call below class from the anonymous window. I am not finding a way to pass IDs as parameter.
I want pass record Ids of Account for example this 0010I00001hMhFIQA0.
___________________________
public class AccountClass {
public static void CountMyContacts(Set<ID> recordIds){
List<Account> accs = [Select Id, Name from Account Where Id IN :recordIds];
for (Account a : accs){
List<Contact> Cons = [Select Id, Name from Contact Where AccountId = :a.Id];
integer ConCount = Cons.size();
system.debug( Account.Name + 'account has' + ConCount + 'number of contacts');
}
}
}
This should work.
Set<ID> idSet = new Set<ID>{'0016F00003AWlgkQAD','0016F00002pCFNPQA4'};
AccountClass.CountMyContacts(idSet);
Regards,
Lakshmi.
All Answers
This should work.
Set<ID> idSet = new Set<ID>{'0016F00003AWlgkQAD','0016F00002pCFNPQA4'};
AccountClass.CountMyContacts(idSet);
Regards,
Lakshmi.