Opportunity Line Items in Salesforce – Learn Here

What are Opportunity Line Items? 

The Products connected to an Opportunity are called OpportunityLineItem. 

There are many different things that a business might sell. These items are collectively referred to as Products. However, “OpportunityLineItem” records are what are created when a Product or a number of Products are associated to an Opportunity.  

There may be one or several opportunity product lines for a single opportunity. 

Opportunity Line Items -Related Objects and Related Lists 

  • Opportunity 
  • Pricebook Entry 
  • Product2 

Don’t forget to check out: All You Need to Know About Apex Testing in Salesforce | The Developer Guide

Creating Opportunity Line Items in Salesforce 

  • On the related tab, click on a new product. 
  • Select a product. 
  • Click Next. 
  • Add quantity. 
  • Click Save. 
  • Opportunity Line Item will be created. 

How Opportunity Line Items are related to Opportunity and Product 

An Opportunity Line Item is related to a Product through the Pricebook Entry Object and related to the opportunity directly. 

What is the difference between Products and Opportunity Line Items?   

Products are the means through which you make money. 

These could be tangible objects. But they could also be setup costs, SaaS licencing, or services. in fact, any additional intangible advantages you give customers. 

In other words, consider your product line as a catalogue of possible purchases for customers. 

Opportunity products are the unique goods and services from that catalogue that you promote in connection with a certain offer or opportunity. 

Benefits of Opportunity Line Items 

  • Improved Salesforce usability 
  • Improve Opportunity Accuracy 
  • Improve Pipeline Visibility 
  • Identify Development Needs 
  • Increase Price Discount Control 
  • Close Deals More Quickly 

dont miss out iconCheck out another amazing blog by Ashish here: Lightning App Manager in Salesforce – All you Need to Know

How to Create Opportunity Line Items using Apex 

//First Step to create a new opportunity and Insert it 
Opportunity opp  = new Opportunity(name="Any Name", ); 
insert opp; 
Pricebook2  standardPb = [select id, name, isActive from Pricebook2 where          IsStandard = true limit 1]; 
Product2 prod = new Product2(); // ----> Create  product 
prod.Name="Test Product"; 
insert prod; 
  //------->Create PriceBookEntry 
PricebookEntry pbEntry = new PricebookEntry ();      pbe1.Product2ID=prd1.id; 
insert pbEntry; 
//-->Create OpportunityLineItem 
OpportunityLineItem oppLI = new OpportunityLineItem();  
oppLI.PricebookEntryId= pbEntry.Id; 
oppLI.OpportunityId = opp.Id; 
oppLI.Quantity = 5; 
 oppLI.TotalPrice = 10.0; 
insert opLineItemlist;  

Source link

Interesting Posts

Leave a Reply

Your email address will not be published. Required fields are marked *