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
Sai Teja 7557Sai Teja 7557 

How to create and what role plays an opportunity line item(opportunity product) in sales process

Can anyone explain the why opportunity line item(opportunity product) is important what is the procedure to create the opportunity line item.
Best Answer chosen by Sai Teja 7557
ShirishaShirisha (Salesforce Developers) 
Hi Sai,

Greetings!

"An Opportunity can have associated OpportunityLineItem records only if the Opportunity has a Pricebook2. An OpportunityLineItem must correspond to a Product2 that is listed in the opportunity's Pricebook2. For information about inserting OpportunityLineItem for an opportunity that does not have an associated Pricebook2 or any existing line items."

So,you need to have the pricebook2 record if you would like to create an Opportunity LineItem(Product2) record.

Reference:https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_opportunitylineitem.htm

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri