I'm getting a very weird scenario for a for loop.
I'm running the following code:
List<Id> conId = new List<Id>();
List<Customer__c> customers = new List<Customer__c>();
customers = [SELECT Id FROM Customer__c WHERE IsValid = false AND Contact__c != null];
for(Customer__c cust : customers){
system.debug(cust.Id);
conId.add((cust.Contact__c));
}
List<Opportunity> opps = new List<Opportunity>();
opps=[SELECT Id, Customer__c FROM Opportunity WHERE Customer__c IN:conId];
if(opps.size() != 0){
for(Opportunity opp : opps){
System.debug(opp.Customer_Contact__c);
}
}
This is used in a batch class and I believe it is causing a Null Pointer Exception error that is causing the batch class to fail.
When I search for null
in the filter of the debug logs on this script, I see VARIABLE_ASSIGNMENT cust | null
in the logs. Is this normal, or is my null value in the batch class related to something else?