function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kalyforminkalyformin 

Query for Opportunity products

I'm quite new to SFDC and trying to find if there is a way to query all products associated with an opportunity.

 

The scenario is I have an opportunity and two associated products. I'm trying to get these products in custom VF page.

 

Any help is appreciated!

shillyershillyer

You could use a Semi-Joins, but this returns all of the Opportunities with Products (Line Items).

 

 

Select o.Name, (Select Quantity From OpportunityLineItems) From Opportunity o Where Id IN (SELECT OpportunityId FROM OpportunityLineItem WHERE Quantity > 0)

 

 

 

Hope that helps,

Sati

HardeepHardeep

That is really helpfulful, can you query the Product family too.