You need to sign in to do that
Don't have an account?
medemaza
Why my loop not working
public class LastOfferPrice { public ID OpportunityID{get; set;} List<OpportunityLineItem> Item; public List<OpportunityLineItem> getItem(){ if(Item==null){ Item = [Select Id,PricebookEntry.Product2.Name,PricebookEntry.Product2Id,ListPrice,UnitPrice,Opportunity.CloseDate,LastModifiedDate From OpportunityLineItem Where OpportunityId=:OpportunityID]; } return Item; } List<Product2> Pro; public List<Product2> getPro(){ for(integer i=0;i<Item.size();i++){ Pro = [Select Id,Name From Product2 where Id=:Item[i].PricebookEntry.Product2Id]; } return Pro; } }
Why my loop not working;
My Item has 7 records and my product 1,354 record but is return only 1 record
I think this is because you aren't adding the information to the list, you are simply returning the results of the last query.
Try changing to: