You need to sign in to do that
Don't have an account?
aqueller
Opportunity Products
I have an opportunity, ExOp that I receive through a query.
Opportunity ExOp = [SELECT name from opportunity
WHERE (AccountId = :o.AccountId and ForecastCategoryName !='Closed')
ORDER BY CloseDate ASC NULLS last LIMIT 1];
I am trying to access the list of product in it. (is it OpportunityLineItem?)
Specifically, I want to get to the 'Product2' and 'quantity' fields.
Can someone suggest code to access it?
use below Query with your Where Condtions
list<Opportunity> lstOpportunity=[SELECT Amount, Id, Name, (SELECT Quantity, ListPrice,PriceBookEntry.UnitPrice, PricebookEntry.Name,PricebookEntry.product2.id FROM OpportunityLineItems) FROM Opportunity where id=:oppId];
Regards,
V'Nath.
I was trying to follow your advice, but am still having problems.
I created the following query:
list<Opportunity> lstOpportunity = [SELECT Amount, Id, Name,
(SELECT Quantity, ListPrice, PriceBookEntry.UnitPrice,
PricebookEntry.Name, PricebookEntry.product2.id
FROM OpportunityLineItems)
FROM Opportunity
WHERE (AccountId = :o.AccountId and ForecastCategoryName !='Closed')
ORDER BY CloseDate ASC NULLS last LIMIT 10];
I would have liked to print a list of products for the opportunity, and their quantity.
I would like to use a statement like:
ExOp.Description = 'Product name ' + listItem[0].name + ' Quantity ' + listItem[0].quantity;
ExOp.Description = 'Product name ' + listItem[1].name + ' Quantity ' + listItem[1].quantity;
How can I do it, using the results of the query above?
Thx,
aqueller