You need to sign in to do that
Don't have an account?

For loop to iterate all record returned in the Query
Hi there, need help, I wrote a query that returns 3 records. and I'm reading those records in the FOR loop to update record that matchs criteria, however this record iteration no happening, anything I'm missing in following code:
my question is, I put a debug before if, I epxcet 3 entries in the log but it just one.
List <Sales_Team__c> gst = [Select Sales_Team_Member__c,Primary__c,Producer__c,Opportunity__c,Email__c,Id
From Sales_Team__c
Where Sales_Team_Member__c IN: opportunityIdSet and Producer__c = null];
for (Sales_Team__c OpptyGST : gst){
system.debug('Test GST Memebr# : ' + OpptyGST.Sales_Team_Member__c);
if (OpptyGST.Sales_Team_Member__c == Oppty.Sales_Rep__c){
OpptyGST.Primary__c = true;
OpptyGST.Email__c = 'primary@gst.com';
}
}
my question is, I put a debug before if, I epxcet 3 entries in the log but it just one.
List <Sales_Team__c> gst = [Select Sales_Team_Member__c,Primary__c,Producer__c,Opportunity__c,Email__c,Id
From Sales_Team__c
Where Sales_Team_Member__c IN: opportunityIdSet and Producer__c = null];
for (Sales_Team__c OpptyGST : gst){
system.debug('Test GST Memebr# : ' + OpptyGST.Sales_Team_Member__c);
if (OpptyGST.Sales_Team_Member__c == Oppty.Sales_Rep__c){
OpptyGST.Primary__c = true;
OpptyGST.Email__c = 'primary@gst.com';
}
}
in your debug log check the line
Number of records returned ----------------- it will show the actual no of records returned
I don't think you have any error in your code .Please chec once more .Check in debug log .
Your debug statement should appear .
DEveloper console >> Query section
Please share your full code.