답변 1개
Hi SFDC resource,Use a Map instead:List<Task> tasks = [SELECT Id ... FROM Task]; Map<Id, Contact> contacts = new Map<Id, Contact>([SELECT Id ... FROM Contact]); for (Task t : tasks){ Contact c = contacts.get(t.WhoId); if(c != null) { //some logic here } }This technique was originally used to avoid script limits, and it's equally effective to avoid timeout limits.EditTask[] tasks = [SELECT Id ... FROM Task WHERE ...];Map<Id, Contact> contacts = new Map<Id, Contact>();for(Task record: tasks) { if(record.WhoId != null && record.WhoId.getSObjectType() == Contact.SObjectType) { contacts.put(record.WhoId, null); } } contacts.putAll([SELECT Id ... FROM Contact WHERE Id IN :contacts.keySet()]);Best RegardsNaga Kiran