Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get the product information using Opportunity line Item.What is the simplest way to query this?

Thanks very much.

share|improve this question
up vote 6 down vote accepted

SOQL allows you to traverse object relationships using dot notation, so for example to get to the Product (and its fields) via the Pricebook on the OpportunityLine you can do this...

Select PricebookEntry.Product2.Name From OpportunityLineItem

Then in Apex use the same path to access the field you need.

String productName = queriedOppLine.Product2.Name;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.