You need to sign in to do that
Don't have an account?
blake.tanon
(Not in Loop?) System.LimitException: Too many SOQL queries: 101
I'm getting the too many SOQL limit on the start of a trigger, the query isn't in a loop but the set of IDs is retrieved in a loop - maybe that is why? If so how could I get around this?
trigger eventTrigger on Event (before insert, before update) { set<ID> owner = new Set<ID>(); for(event t:trigger.new) owner.add(t.ownerid); List<User> u = [SELECT Id, UserRole.Name FROM USER WHERE id in: owner LIMIT 1]; //logic below }
That shouldn't give you a problem - you only have a single SOQL query there.
Are there other triggers firing in this transaction? If not, can you post the rest of your trigger code?
what is the logic below? is there any other queries? or this may be recursive trigger?
I just realized I have two triggers on Event that are running an query to users, although they are both outside of a loop and run on a set of IDs. When I disable either they other will pass, I will try to combine them into one trigger and see how it goes.
Here is the full trigger
first change should be you should update the contact after all the loops end....and also you can update the looping object so you need to declare a list object and add the loop object to that and do the update on the list