You need to sign in to do that
Don't have an account?
XIO
Help with ERROR: System.LimitException: Too many SOQL queries: 101
Hello everyone!
I have a trigger (below) that is excluding the User Role 'Research' so that role can perform bulk updates on that object. The triggers works fine when you update individual records and up to 100 records for bulk updates. If we exceed 100 records for our bulk updates we receive the following error:
System.LimitException: Too many SOQL queries: 101
Any assistance with this trigger is greatly appreciated!!
I have a trigger (below) that is excluding the User Role 'Research' so that role can perform bulk updates on that object. The triggers works fine when you update individual records and up to 100 records for bulk updates. If we exceed 100 records for our bulk updates we receive the following error:
System.LimitException: Too many SOQL queries: 101
Any assistance with this trigger is greatly appreciated!!
trigger SurveyHandling on Relationship_to_Initiative_Research__c (after insert,after delete,after update) { list<Id> rlist4=new list<Id> (); list<Initiatives__c > rlsit5=new list<Initiatives__c >(); //////////// insert and update operation if(trigger.isinsert || trigger.isupdate){ for(Relationship_to_Initiative_Research__c i : trigger.new) {UserInfo.getUserRoleId(); List<String> exemptedRoles = new List<String>(); exemptedRoles.add('ATeam'); list<UserRole> IsItExemptedRole=[select id,name from UserRole where name in :exemptedRoles and id=:UserInfo.getUserRoleId()]; if(IsItExemptedRole.size()<=0){ { rlist4.add(i.Initiative_Title__c ); } Initiatives__c ini=[select id,Action_ItemsRICHTEXT__c,Progress__c,Timeframe__c,Owner__c from Initiatives__c where id in:rlist4]; for(Relationship_to_Initiative_Research__c rr:trigger.new){ ini.Action_ItemsRICHTEXT__c=rr.Action_Item_ScriptRICHTEXT__c ; ini.Progress__c=rr.Progress__c ; ini.Timeframe__c=rr.Timeframe__c ; ini.Owner__c=rr.Owner__c ; rlsit5.add(ini); } update rlsit5; } /////////////// Delete operation start if(trigger.isdelete){ for(Relationship_to_Initiative_Research__c ii : trigger.old) { rlist4.add(ii.Initiative_Title__c ); } Initiatives__c ini=[select id,Action_ItemsRICHTEXT__c,Progress__c,Timeframe__c,Owner__c from Initiatives__c where id in:rlist4]; for(Relationship_to_Initiative_Research__c rr:trigger.old){ ini.Action_ItemsRICHTEXT__c=rr.Action_Item_ScriptRICHTEXT__c ; ini.Progress__c=rr.Progress__c ; ini.Timeframe__c=rr.Timeframe__c ; ini.Owner__c=rr.Owner__c ; rlsit5.add(ini); } update rlsit5; } } } }
Thanks
Wade