• happy dev
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

I have trigger to update Account depending on the order call data input.  The first and the third checking work and can update Account successfully.  However, the second one checking the "'1yr RP Quit" always shows the error "System.NullPointerException: Attempt to de-reference a null object" when it does "acclist.get(oc.Member__c).X1yr_Reserve_Program__c = FALSE".  Anyone can know why?

 

 

  Set<Id> accIds = new Set<Id>();

  for(Order_Call__c oc: Trigger.new){  

      if(oc.Call_Purpose__c == 'Order' || oc.Agreed_to_join_1yrRP__c == True ||  

         oc.Call_Purpose__c == '1yr RP Quit'){  

         accIds.add(oc.Member__c);

      }//end if    

  }//end for     

  Map<Id,Account> acclist = new Map<Id,Account>([select id, Last_Order_Date__c, X1yr_Reserve_Program__c, X1yrRP_Joined_Date__c,

              X1yrRP_Quit_Date__c, No_Of_Orders__c from Account where id in :accIds]);       

  for(Order_Call__c oc:Trigger.new){           

      if(oc.Call_Purpose__c == 'Order'){

         acclist.get(oc.Member__c).Last_Order_Date__c = oc.Order_Date__c;    

         string a = string.valueOf(acclist.get(oc.Member__c).No_of_Orders__c);      

         if(a == NULL){      

            acclist.get(oc.Member__c).No_of_Orders__c = 0;         

         }//end if 

         acclist.get(oc.Member__c).No_of_Orders__c = acclist.get(oc.Member__c).No_of_Orders__c + 1;      

      //end if        

      if(oc.Call_About__c == '1yr RP Quit'){        

         acclist.get(oc.Member__c).X1yr_Reserve_Program__c = FALSE;

         acclist.get(oc.Member__c).X1yrRP_Quit_Date__c = date.today();       

      }//end if         

      if(oc.Agreed_to_join_1yrRP__c == True){          

         acclist.get(oc.Member__c).X1yr_Reserve_Program__c = TRUE;

         acclist.get(oc.Member__c).X1yrRP_Joined_Date__c = date.today();

      }//end if            

  }//end for          

 

  update(acclist.values());

 

}

I have code to draw around 200 districts from a custom object.  It works fine in sandbox but failed when it is deployed to production.  Anyone knows why?  The error is "Too many SOQL queries: 101", Failure Stack Trace: "

 

 

    Map<Id, District__c> DistrictById = new Map<Id, District__c>([SELECT Id, Name FROM District__c]);

 

 

Thanks

I have trigger to update Account depending on the order call data input.  The first and the third checking work and can update Account successfully.  However, the second one checking the "'1yr RP Quit" always shows the error "System.NullPointerException: Attempt to de-reference a null object" when it does "acclist.get(oc.Member__c).X1yr_Reserve_Program__c = FALSE".  Anyone can know why?

 

 

  Set<Id> accIds = new Set<Id>();

  for(Order_Call__c oc: Trigger.new){  

      if(oc.Call_Purpose__c == 'Order' || oc.Agreed_to_join_1yrRP__c == True ||  

         oc.Call_Purpose__c == '1yr RP Quit'){  

         accIds.add(oc.Member__c);

      }//end if    

  }//end for     

  Map<Id,Account> acclist = new Map<Id,Account>([select id, Last_Order_Date__c, X1yr_Reserve_Program__c, X1yrRP_Joined_Date__c,

              X1yrRP_Quit_Date__c, No_Of_Orders__c from Account where id in :accIds]);       

  for(Order_Call__c oc:Trigger.new){           

      if(oc.Call_Purpose__c == 'Order'){

         acclist.get(oc.Member__c).Last_Order_Date__c = oc.Order_Date__c;    

         string a = string.valueOf(acclist.get(oc.Member__c).No_of_Orders__c);      

         if(a == NULL){      

            acclist.get(oc.Member__c).No_of_Orders__c = 0;         

         }//end if 

         acclist.get(oc.Member__c).No_of_Orders__c = acclist.get(oc.Member__c).No_of_Orders__c + 1;      

      //end if        

      if(oc.Call_About__c == '1yr RP Quit'){        

         acclist.get(oc.Member__c).X1yr_Reserve_Program__c = FALSE;

         acclist.get(oc.Member__c).X1yrRP_Quit_Date__c = date.today();       

      }//end if         

      if(oc.Agreed_to_join_1yrRP__c == True){          

         acclist.get(oc.Member__c).X1yr_Reserve_Program__c = TRUE;

         acclist.get(oc.Member__c).X1yrRP_Joined_Date__c = date.today();

      }//end if            

  }//end for          

 

  update(acclist.values());

 

}