function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bruce HansonBruce Hanson 

Apex governor limit warning

I could use some help solving an Apex governor limit warning issue. I have two problems.  First, I don't know for sure which trigger or class is causing the error (but I think I know) ... and ... I don't know how to fix the trigger (assuming I'm correct about the culprit).  
Assuming I'm right, the trigger below is the culprit.  In short, its simple purpose is to set the account record type based on a custom formula field that derives its values from a custom picklist field.  The trigger works just as I expect it to.  However, when I try to use API tools like dataloader, I get the governor limit warnings.  I have it set up to send me an email until I get it solved.  If possible, please give guidance on how I can determine for sure what is the cause, and if you agree the below trigger is the cause, any assistance in 'bulkifying' this trigger is much appreciated.  

trigger SET_ACCOUNT_RTYPE_TRIGGER2 on Account (before insert, before update) {
Map<String, Id> typeMap = New Map<String, Id>();

   for(RecordType RT: [Select DeveloperName, Id From RecordType Where sObjectType = 'Account']) {
      typeMap.put(RT.DeveloperName, RT.Id);
   for (Account ACT :  {
             id recid = typeMap.get(ACT.Rtype_FM__c);
             recordtype rectype = [select id, developername from recordtype where id=:recid];
            ACT.RecordTypeid =; 
Grace Patiño PérezGrace Patiño Pérez
I think this query ([Select DeveloperName, Id From RecordType Where sObjectType = 'Account']) is returning too much records. You must Start to do "SOQL for loops" (its a best practice):
for(List<RecordType> RTS: [Select DeveloperName, Id From RecordType Where sObjectType = 'Account']) {
i hope it helps! :D