Skip to main content
Hi,

In visualforce controller I am getting the "Error:CPU limit exceeded".In order to avoid this error I am using Future handler in visualforce controller.But after using it ,it is popping another error "[Fatal Error]:Salesforce Internal Error".Can anybody suggest me a solution for this?

Thanks.
답변 1개
  1. 2015년 8월 7일 오전 9:54
    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.

    Edit

    Task[] 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 Regards

    Naga Kiran

     
0/9000