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
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.
The schema behind Salesforce Products is the following:
Product2 --> PricebookEntry <-- Pricebook2
That is, one Product has many PricebookEntries (junction record) . Listprice can be fetched from the related PricebookEntry, for a given Pricebook.
I hope this brings some light.
Try to take a look at the Schema in your Salesforce instance by going to Setup -> Schema Builder and select there the objects listed above. It will help you visualizing the query you want to make :-)
This is also a good reference: developer.salesforce.com/docs/atlas.en-us.object_reference.meta/… Jul 28, 2015 at 13:37
ListPrice__cin order to get that field