Loading

Salesforce Platform: OpportunityLineItem Insert Field Integrity Error

Udgivelsesdato: Mar 31, 2026
Beskrivelse
OpportunityLineItem is a standard Salesforce object that represents the association between an Opportunity and the products (from the Product Catalog) being sold. Each record defines a specific product added to an Opportunity, including details such as quantity, sales price, and total amount. It is commonly referred to as an Opportunity Product and is used to track line-level sales details within a deal.
 
When inserting the OpportunityLineItem, you may receive the following error :
 

Error Message

Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId, unknown (versions 3.0 and higher must specify pricebook entry id; others must specify product id): [PricebookEntryId, unknown] 

 
 
Note:  "version 3.0 and higher" refers to the api version.  This error message has not been updated but should read:


Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId, unknown (all API versions must specify pricebook entry id; others must specify product id): [PricebookEntryId, unknown] 
 

Common Causes

When adding a product to an Opportunity, you are creating an OpportunityLineItem record. This record acts as a link between the Opportunity and a specific product at a specific price. In Salesforce, this price is defined by a PricebookEntry record, not just the Product record. The PricebookEntry represents a product's price within a specific Price Book (e.g., Standard Price Book, US Price Book).

This error occurs because the code is attempting to create an OpportunityLineItem without providing the required PricebookEntryId. Modern Salesforce APIs require you to specify the exact price listing (PricebookEntryId) for the product you are adding to the Opportunity.

Løsning

Resolution Steps

Use 'Product2Id' filter. For e.g: 
List<PricebookEntry> pbe = [select id, name, CurrencyIsoCode from PriceBookEntry where Pricebook2id =: 'VALUE' and Product2Id in: VALUE.keySet() ];


Vidensartikelnummer

000383141

 
Indlæser
Salesforce Help | Article