You need to sign in to do that
Don't have an account?
iSqFt_AD
Activity Roll Up Trigger throwing System.LimitException error - How to fix??
I found this trigger and made a couple changes to it in attempts to get a simple roll up count of activities in the Activity History of Accounts.
trigger Activity_Count_2 on Task (after insert, after update, after delete, after undelete) { List<Account> uplist=new List<Account>(); List<Account> lelist=[select id,Activity_Count_2__c from Account]; List<AggregateResult> st=new List<AggregateResult>(); st=[select count(Id),whoid from task where id=:Trigger.new and status='Completed' group by whoid]; for(Integer i=0;i<st.size();i++) { for(Account a:lelist) { if(a.id==st[i].get('whoid')) { a.Activity_Count_2__c=(Integer)st[i].get('expr0')+a.Activity_Count_2__c; uplist.add(a); } } } update uplist; }
Unfortunately, when I went to log an activity at the Account I received this error:
"Apex trigger Activity_Count_2 caused an unexpected exception, contact your administrator: Activity_Count_2: System.LimitException: Too many query rows: 50001"
What am I missing here?
try this
All Answers
Try this.
Error: Compile Error: unexpected token: '{' at line 13 column 8
I have edited my previous post.
check it.
Hi Naidu,
I thought I knew how to fix this but no matter the changes I make I keep getting this error:
Error: Compile Error: Variable does not exist: WhatId at line 24 column 23
It looks like you called it out correctly, but what am I missing?
Thank you as always for your assistance.
Please try the code again. i have edited it.
Boo!
Error: Compile Error: Incompatible key type Object for MAP<Id,Integer> at line 24 column 13
Try this.
You are quite patient and I thank you for your help.
Still getting this error now - Error: Compile Error: Variable does not exist: updateList at line 38 column 16
Try the above edited post.
Error: Compile Error: Method does not exist or incorrect signature: accMap.put(Id, SOBJECT:Account) at line 22 column 13
I even tried to edit acMap to accMap but then I received this error: Error: Compile Error: Incompatible key type Object for MAP<Id,Account> at line 29 column 19
try this
Unfortunately its the same error - Error: Compile Error: Incompatible key type Object for MAP<Id,Account> at line 31 column 19
I have edited the class. Try it.
I originally got the error - Error: Compile Error: Invalid field Activity_Count_2 for SObject Account at line 32 column 13
Then I edited the line in the error to:
but I get this error now: Error: Compile Error: Illegal assignment from Object to Decimal at line 32 column 13
I cannot figure out where you used a decimal wrong here.
Edited the post. check it.
It appears this was fixed correctly. Thank you Naidu!
in the query at not in condition
List<Customer__C> listPLAccMgrs = [Select id,Account_Manager__c,Account__c
FROM Customer_Prac__c
WHERE ACCOUNT__C
in:setAcctIds1 and id not in:trigger.newmap().keyset()];