• Nano Randy
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi,
I have a trigger. when I'm trying to update data through dataloader, I getting Soql 101 query limit error
trigger Approvers on Approval__c (before insert,before update)
{
Boolean assigned ;
list<Approver__c> lstApprover;
for(Approval__c c:trigger.new)
{
 if(c.Category__c=='Dental' || c.Category__c=='General')
 {
 lstApprover = [Select Bill__c, Approver_1__c, Approver_2__c,Category__c,Market__c,Reason__c, Id, RecordTypeId, Region__c, Division__c, Sub_Division__c,Zone__c 
 from Approver__c where  reason__c= :c.reason__c and  Category__c=:c.Category__c order by Bill__c asc];
 assigned = false;
}
}
if(lstApprover.size()>0 && c.Status__c!='Approved'){
    
for(Approver__c tmplstApprover :  lstApprover ){
if(assigned == false && c.Bill__c < tmplstApprover.Bill__c){
            c.Approver_1__c=tmplstApprover.Approver_1__c;
            c.Approver_2__c=tmplstApprover.Approver_2__c;
             c.Approver__c= tmplstApprover.id; 
            assigned = true;
          }
    }
}

}

Thanks  in Advance.