You need to sign in to do that
Don't have an account?
hylim1215
please help with my trigger "Too many SOQL queries: 101" error
Hi,
I have an after update trigger like this
but i got error email from salesforce saying that Too many SOQL queries: 101 on this trigger when my user updating contact. Any thought?
I have an after update trigger like this
List<id> acc_ids = new List<id>(); List<Account> acc_toUpdate = new List<Account>(); if(trigger.isUpdate){ for(Contact ctc:Trigger.new){ Contact oldctc = trigger.oldMap.get(ctc.id); if(ctc.value__c != oldctc.value__c){ acc_ids.add(ctc.AccountId); } } } if(acc_ids.size() > 0){ // List<Account> acc = new List<Account>(); for(Account acc: [Select id, CalculateALC__c from Account where id in: acc_ids]){ acc.CalculateALC__c = true; acc_toUpdate.add(acc); } } if(acc_toUpdate.size() > 0){ update acc_toUpdate; }
but i got error email from salesforce saying that Too many SOQL queries: 101 on this trigger when my user updating contact. Any thought?
All Answers
I tried it in my org and i am not getting any error and my account is getting updated. Please post the full code also try if there is any other trigger present on contact or account.
thanks