Take the 2-minute tour ×
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.

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
add comment

1 Answer

up vote 3 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
add comment

Your Answer

 
discard

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.