+ Start a Discussion
d.tejdeep@nicomatic.ind.tejdeep@nicomatic.in 

getting 101 soql query error on this code

@AuraEnabled
    public static list<batch__c> SaveBatchDet(integer QliRowNum,list<Batch__c> Bt,map<integer,list<batch__c>> Rowmap,string QuoteID){
          system.debug(QliRowNum+'-------------'+Bt+'@@@@@@@@@@@@@@@@'+Rowmap+'###################'+QuoteID); 
         System.debug('1.Number of Queries used in this apex code so far: ' + Limits.getQueries());
         System.debug('2.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
        //transient List<Integer> sortkey=new List<Integer>();
         Map<Integer,list<batch__c>> batchMap =  New Map<Integer,list<batch__c>>();
            batchMap.put(Integer.valueOf(QliRowNum),Bt);
         transient List<Batch__c> batchListToInsert =new List<Batch__c>();
        
         Map<integer,quote_line_item__c> qouteLineItemMap = new Map<integer,quote_line_item__c>();
		for(quote_line_item__c t: [SELECT QliRowNum__c, Id FROM quote_line_item__c WHERE quote1__c=:QuoteID])
         qouteLineItemMap.put(Integer.valueOf(t.QliRowNum__c), t);
        
        transient List<Integer> sortkey=new List<Integer>();
        sortkey.addAll(qouteLineItemMap.keySet());
      for(integer qli:sortkey){
          if(batchMap.get(qli)!=null)
            for(Batch__c bat: batchMap.get(qli)){
                if(bat.Asked_Qty__c!=null && bat.Asked_Qty__c!=''){
                bat.Quote_Line_Item__c=qouteLineItemMap.get(qli).id;
                }
                if(bat.Quote_Line_Item__c!=null)
                batchListToInsert.add(bat);
               // system.debug(batchListToInsert);
            }//End of for 
        }// End of for
        // Inserting the list of batches
        try{
        
          upsert batchListToInsert ;
           System.debug('1.Number of Queries used in this apex code so far: ' + Limits.getQueries());
         System.debug('2.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
            //system.debug(batchListToInsert);
        }catch(DmlException de){
            return null;
        }
        return null;
    }

i am getting error in this query 
 
for(quote_line_item__c t: [SELECT QliRowNum__c, Id FROM quote_line_item__c WHERE quote1__c=:QuoteID])
is there is any workaround to solve this issue?

Could some help me is there is any wrong in my code?

 
Shubham4462Shubham4462
Try this once
 
@AuraEnabled
    public static list<batch__c> SaveBatchDet(integer QliRowNum,list<Batch__c> Bt,map<integer,list<batch__c>> Rowmap,string QuoteID){
          system.debug(QliRowNum+'-------------'+Bt+'@@@@@@@@@@@@@@@@'+Rowmap+'###################'+QuoteID); 
         System.debug('1.Number of Queries used in this apex code so far: ' + Limits.getQueries());
         System.debug('2.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
        //transient List<Integer> sortkey=new List<Integer>();
         Map<Integer,list<batch__c>> batchMap =  New Map<Integer,list<batch__c>>();
            batchMap.put(Integer.valueOf(QliRowNum),Bt);
         transient List<Batch__c> batchListToInsert =new List<Batch__c>();
        
         Map<integer,quote_line_item__c> qouteLineItemMap = new Map<integer,quote_line_item__c>();
 List<quote_line_item__c > quote2=[SELECT QliRowNum__c, Id FROM quote_line_item__c WHERE quote1__c=:QuoteID];

		for(quote_line_item__c t:quote2)
         qouteLineItemMap.put(Integer.valueOf(t.QliRowNum__c), t);
        
        transient List<Integer> sortkey=new List<Integer>();
        sortkey.addAll(qouteLineItemMap.keySet());
      for(integer qli:sortkey){
          if(batchMap.get(qli)!=null)
            for(Batch__c bat: batchMap.get(qli)){
                if(bat.Asked_Qty__c!=null && bat.Asked_Qty__c!=''){
                bat.Quote_Line_Item__c=qouteLineItemMap.get(qli).id;
                }
                if(bat.Quote_Line_Item__c!=null)
                batchListToInsert.add(bat);
               // system.debug(batchListToInsert);
            }//End of for 
        }// End of for
        // Inserting the list of batches
        try{
        
          upsert batchListToInsert ;
           System.debug('1.Number of Queries used in this apex code so far: ' + Limits.getQueries());
         System.debug('2.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
            //system.debug(batchListToInsert);
        }catch(DmlException de){
            return null;
        }
        return null;
    }


 
d.tejdeep@nicomatic.ind.tejdeep@nicomatic.in
Sorry not working still same error