You need to sign in to do that
Don't have an account?
Glen.ax1034
Schema.SObjectField
I can't seem to figure out why I can't get this code to pull the Name of the product?
public class packageextensions { private final Packages__c PackageObj; public packageextensions (ApexPages.StandardController controller) { this.PackageObj= (Packages__c)controller.getSubject(); } public List<Product2> getgProducts() { //options.add(new Product2('None')); List<Product2> returnProducts = new List<Product2>(); List<Packages__c> origPackage = new List<Packages__c>(); origPackage = [select Opportunity__c from Packages__c where id=:PackageObj.Id Limit 1]; List<OpportunityLineItem> origOpportunityLineItem = new List<OpportunityLineItem >(); origOpportunityLineItem = [Select PricebookEntryId from OpportunityLineItem where OpportunityId =:origPackage[0].Opportunity__c]; for(OpportunityLineItem presentopp : origOpportunityLineItem) { List<PricebookEntry> pbe = new List<PricebookEntry>(); pbe = [Select Product2Id from PricebookEntry where id=:presentopp.PricebookEntryId]; List<Product2> productitem = new List<Product2>(); productitem = [Select Name, Id from Product2 where id=:pbe[0].Product2Id]; returnProducts.add(productitem[0]); debug.print(productitem[0].Name); //I CAN'T SEEM TO GET TO THE SUBCOMPONENTS FROM THE QUERY 3 Lines Above! } //List<Product2> productitem2 = [Select Name, Id from Product2 where id=:pbe[0].Product2Id]; return returnProducts; } }
Hi,
Use system.debug instead of debug.print;
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.