[SalesForce] how to soql query on standard object product2

Im querying on Product 2 as [select id,name,ListPrice ,Quantity from Product2]; but it throws an Error as :No such column 'ListPrice' on entity 'Product2'.Do i need you to use opportunitylineitem or product2 in soql query.Any help plz

Best Answer

If you are trying to run a query to find the product2ID, the name of the product, quantity sold and the list price for a particular opportunity you could run a SOQL query on the OpportunityLine Item.

Your query would look something like this :

SELECT product2ID, product2.name, quantity, Listprice 
FROM OpportunityLineItem 
WHERE OpportunityId = "your opportunity id"

The amount of rows returned would depend on how many products and line items you have in the opportunity.

Related Topic