1

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

3
  • to me it looks like ListPrice is a custom field, so you will have to use ListPrice__c in order to get that field
    – Novarg
    Commented Nov 10, 2014 at 12:50
  • You probably meant standard 'List Price' field which actually has API name of 'UnitPrice'
    – IvanR
    Commented Nov 10, 2014 at 16:15
  • @Ivan,@Novarg:List Price is a standard field for opportunity line item.api name is ListPrice , for 'Salesprice' the Api name is "UnitPrice"
    – nikkey
    Commented Nov 10, 2014 at 17:51

2 Answers 2

2

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.

1

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 :-)

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .