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
Chidanand Magadum 24Chidanand Magadum 24 

Create OpportunityLineItem for an Opportunity

Hi guys,
How to create an Opportunity Line Item for an opportunity Using API?(Apex)
Himanshu ParasharHimanshu Parashar

List<PriceBookEntry> priceBookList = [SELECT Id, Product2Id, Product2.Id, Product2.Name FROM PriceBookEntry WHERE Product2Id='certain_id' AND PriceBook2.isStandard=true LIMIT 1];
OpportunityLineItem oli = new OpportunityLineItem();
/*rest of required fields*/
insert oli;
Arunkumar RArunkumar R
Hi Chidanand,

Please go through the below link it will helpful,