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
Sylvain@RibbonFishSylvain@RibbonFish 

Opportunity, Account and Product.

Hi everyone,

In my application I have to create a sale opportunity for each Account selected with the products selected.

So let's resume I got the accountIDs, productIds and I have to create the sale opportunity.

What I don't understand in the schema page on salesforce, it shoes OpportunityLineItem is composed of a Product2 which I can't find with the schema explorer on the IDE.

So how I can link my new OpportunityLineItem to a product ?

Thanks 

Sylvain

Best Answer chosen by Admin (Salesforce Developers) 
crop1645crop1645

OpportunityLineItem is linked to a PricebookEntry that in turn refers to a Product2

 

Put another way, PricebookEntries are the junction between a Pricebook2 and a Product2 - since an OpportunityLineItem may be for only one currency, and a given Product2 may have prices in multiple currenices, a PricebookEntry serves as the junction between a PriceBook X and the Product2, with rows for each offered currency.

 

Similarly, if a Product can be on two pricebooks (say, Direct and Channel) with different prices on each, then the PricebookEntry serves as the junction between the Product2 and each of the different Pricebooks