I am getting a Too many SOQL queries: 101
error on a trigger when I am trying to deploy another trigger.
I am posting the trigger which is causing the error.
trigger rollupAccountShowings on Account (before insert, before update) {
if (trigger.isinsert) {
for (Account a:Trigger.new){
a.No_of_Viewings__c = 0;
}
} else {
for (account a : [select
id,
(select id from pb__Showings__r)
from account
where id in:trigger.new LIMIT 1]) {
trigger.newMap.get(a.id).No_of_Viewings__c = a.pb__Showings__r.size();
}
}
Can anyone correct me where I have gone wrong and suggest me the changes.
Thanks