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
SFDCDeve_SynSFDCDeve_Syn 

Too many script statements: 10201:

  Hi All,

            I am getting an error Too many script statements: 10201. Please provide your suggestion for the same.

In below code: I m trying to update location object while its a child object of Quote and Quote is the child object of an Opportunity.

  we have one checkbox on Opportunity and it should be true or false for the below query.
*********************************

 public static void checkAllocationPricesUpdate(Location__c[] locationArr)
    { 
     System.debug('TOTAL LOCATIONS ARE -----'+ locationArr);
     Set<Id> my_QuoteId = new Set<Id>();
   for (Location__c OLoc : locationArr)
      {
       my_QuoteId.add(OLoc.OpportunityProduct__c);
      }
     Map<Id, Quote_Line__c> my_OpprQuotMap = new Map<Id, Quote_Line__c>(
     [Select SalesPrice__c, Opportunity__c, LostCode__c From Quote_Line__c where id in :my_QuoteId]);
     Set<Id> my_OpporId = new Set<Id>();
      for (Quote_Line__c quot : my_OpprQuotMap.values())
      {
       my_OpporId.add(quot.Opportunity__c);
      } 
      System.debug('TOTAL QUOTE IDS ARE -----'+ my_QuoteId);
     Map<Id, Quote_Line__c> my_OpprQuotIdsMap = new Map<Id, Quote_Line__c>(
     [Select Id,SalesPrice__c, Opportunity__c, LostCode__c From Quote_Line__c where Opportunity__c in :my_OpporId]);
     Map<Id, Opportunity> my_OpprMissMatchChkBoxMap = new Map<Id, Opportunity>();
     //[select Mismatched_Allocation__c from Opportunity where id in :my_OpporId]);
     Map<Id,Location__c> my_OpprlocAllocatedPrice = new Map<Id,Location__c>(
     [Select OpportunityProduct__c, Id, AllocatedPrice__c From Location__c  where OpportunityProduct__c in :my_OpprQuotIdsMap.keySet()]);
  System.debug('STATUS OF LOCATION -----'+ my_OpprlocAllocatedPrice);
     //for (Opportunity opp : my_OpprMissMatchChkBoxMap.values())
    // {         
     // opp.Mismatched_Allocation__c = false;
      Integer iTest = 0;
      for (Quote_Line__c quot : my_OpprQuotIdsMap.values())
      {
       System.debug('INSITE OF QUOTE');
       if(my_OpprQuotIdsMap.get(quot.id).LostCode__c == Null)
       {
        Double sum = 0.00;                  
        for (Location__c opploc : my_OpprlocAllocatedPrice.values())
        { 
             if (my_OpprlocAllocatedPrice.get(opploc.Id).AllocatedPrice__c==null)
             {
              opploc.AllocatedPrice__c = 0;
              System.debug('VALUE OF ALLOCATED PRICE'+ opploc.AllocatedPrice__c);
             }
          if(quot.id ==opploc.OpportunityProduct__c)
          {
           sum = sum+ my_OpprlocAllocatedPrice.get(opploc.Id).AllocatedPrice__c;
           System.debug('ADDING THE VALUE'+sum);
          }  
        }
        if( my_OpprQuotIdsMap.get(quot.Id).SalesPrice__c != sum.round())
        {     
         iTest = 1;
         
        }
        else
        {
          Opportunity o =new Opportunity(ID = quot.Opportunity__c,Mismatched_Allocation__c=false);
                         my_OpprMissMatchChkBoxMap.put(o.Id,o);
         // o.Mismatched_Allocation__c = false;
         
         // my_OpprMissMatchChkBoxMap.put(o.Mismatched_Allocation__c,o);
          System.debug('Have Fun--->'+ o.Mismatched_Allocation__c);
        }       
       }       
      }
      if(iTest==1)
      {
       //opp.Mismatched_Allocation__c = true;   // Ori value
       for (Quote_Line__c quot : my_OpprQuotIdsMap.values())
      {
       Opportunity o =new Opportunity(ID = quot.Opportunity__c,Mismatched_Allocation__c=true);
                my_OpprMissMatchChkBoxMap.put(o.Id,o);
       //my_OpprMissMatchChkBoxMap.put(o.Mismatched_Allocation__c,o);
       System.debug('Have Fun_Part2--->'+ o.Mismatched_Allocation__c);
      }
      }
      //update opp;
     //} End
      if(my_OpprMissMatchChkBoxMap.size()>0){
            if(my_OpprMissMatchChkBoxMap.size()+Limits.getDmlRows()< Limits.getLimitDmlRows()){//Handling governor limit.
                try{                  
                     update my_OpprMissMatchChkBoxMap.values();  
                      System.debug('UPDATE OPPORTUNITY'+ my_OpprMissMatchChkBoxMap.values());                                  
                }catch(Exception Ex){
                 System.debug('Actual error is --'+ Ex.getMessage());
                    //throw Ex;
                }
            }
            else{//Throwing custom exception message.           
                throw new GovernerLimitException('GOVERNOR_LIMIT');
            }
        }    
    }

imuino2imuino2

As far as i know theres a 10000 limit of rows when doing a query.

So you are beyond that limit for 201 row.