You need to sign in to do that
Don't have an account?
Glen.ax1034
SOQL Compilation Query Assistance
I am trying to write a packageextensions class that will return a list of Product2 so that I can allow the user to choose which products go into a package. I finally figured out how they are all linked together, but my SOQL skills and LIST skills are not up to the level required to write this. Here is how it all links together:
Part 2 is a list, I recognize that. I need to convert these SOQL statements so that they all go together and result in a list of products. Any ideas? Are these nested SOQL statements? Do I need mapping?
First: Select Opportunity__c from Packages__c where id='a3FT00000009YHV' returns: '006T0000008rbgtIAA' which is the opportunity associated with the package. every package only has one opportunity. Second: Select Id from OpportunityLineItem where OpportunityId = '006T0000008rbgtIAA' returns: '00kT0000006XzBMIA0' '00kT0000006Z6csIAC' '00kT0000006YgMHIA0' '00kT0000006YWuqIAG' Third: Select PricebookEntryId from OpportunityLineItem where id='00kT0000006XzBMIA0' returns: '01u70000003P4sNAAS' (which is the productcode id) Lastly: Select Product2Id from PricebookEntry where id='01u70000003P4sNAAS' returns: '01t700000017VVBAA2' (which is the product2 id, hurray!) Confirm: Select Name from Product2 where id='01t700000017VVBAA2' --- this returns the product name. score!
public class packageextensions { private final Packages__c PackageObj; public packageextensions (ApexPages.StandardController controller) { this.PackageObj= (Packages__c)controller.getSubject(); } public List<Product2> getProducts() { //Opportunity op = [Select PackageObj.Opportunity from Package__c]; //List<Product2> products = [select id from OpportunityLineItem where Opportunity__c =:op.id]; return products; } }
Not sure if understood the question correctly. Are you trying to develop a managed package extension, where extension needs to pass some detail to parent package class ?
Great question. I am trying to plug it all into a visualforce page:
The idea is that when I pick a specific package, it pulls from the opportunity that it is linked to all of the products presently listed in that opportunity so that I can add them to a package.
Thoughts?
Getting closer...
SELECT Amount, Id, Name, (SELECT Quantity, ListPrice,
PriceBookEntry.UnitPrice, PricebookEntry.Name,
PricebookEntry.product2.Family FROM OpportunityLineItems)
FROM Opportunity
Why are you printing product list like this
You can use apex:repeat to create required markup, or use apex:pageBlocktable or apex:dataTable.