You need to sign in to do that
Don't have an account?
Trigger is giving error : d by: System.QueryException: Non-selective query against large object type (more than 100000 rows)
Hi,
Can U please modify this trigger to call Future class. May be this solution work.
Can U please modify this trigger to call Future class. May be this solution work.
Trigger TaskTrigger on Task(after insert, after delete, after undelete) { Set<Id> accountIds = new Set<Id>(); for(Task tsk : trigger.isDelete ? trigger.old : trigger.new) { accountIds.add(tsk.AccountId); } AggregateResult[] groupedResults = [SELECT Count(Id), AccountId FROM Task group by AccountId having AccountId in: accountIds]; Map<Id,Integer> taksCountMap = new Map<Id,Integer>(); for (AggregateResult ar : groupedResults) { taksCountMap.put((Id)ar.get('AccountId'),Integer.valueOf(ar.get('expr0'))); } List<Account> accUpdLst = new List<Account>(); //Updating the count field for(Task tsk: trigger.new) { if(taksCountMap.containsKey(tsk.AccountId)) accUpdLst.add(new Account(Id = tsk.AccountId,count__c = taksCountMap.get(tsk.AccountId))); } if(accUpdLst.size() > 0) { update accUpdLst; } }
http://help.salesforce.com/HTViewSolution?id=000002493