+ Start a Discussion
msimondsmsimonds 

Field Integrity exception on Opportunity Line Item Creation

I was wondering if anyone has come across this API return message:

 

 

[message] => field integrity exception: PricebookEntryId, unknown (versions 3.0 and higher must specify pricebook entry id; others must specify product id)

 

 I have not seen this, but I do understand what is asking. The reason why I am posting this is because:

 

How are we supposed to know what the version is when we are creating an opportunity line item?

 

If somone could please share that with me, I will be greatful

 

 

Thanks,

~Mike 

 

Ron HessRon Hess

This is the message that occurs if you attempt to add an opp line item to an opp that has no price book selected.

 

so, my guess is the pricebook entry is null in your insert.

Mahesh_BMahesh_B

Even I'm hitting the same issue.  I have checked the Opportunity and there is an Price Book listed to that.

 

I'm passing the PricebookentryId which is active and the Product is also active.  Not sure what else I need to look into.

 

Any help is highly appreciated. This is quite urgent as well.

 

-Mahesh

Mahesh_BMahesh_B

I figured out the issue,  if the product status is inactive (i.e. Active checkbox is not checked) then this error would occur.

 

-Mahesh.

bvdbbvdb

Hi,

 

I changed the item from inactive to active and I still receive the following message:

 

Version:0.9StartHTML:-1EndHTML:-1StartFragment:0000000111EndFragment:0000000436

field integrity exception: PricebookEntryId, unknown (versions 3.0 and higher must specify pricebook entry id; others must specify product id).

  

 

Mahesh_BMahesh_B

I have seen this in past but do not recollect it now...  I think this error occurs when there is no standard price for the product and you are trying to upsert the lineitem

Kumar.sforKumar.sfor

could someone please post the solution for this?

iffuiffu

This error usually pops up when you try to insert wrong value to some field or (even) correct value to the inactive record. I too got this error while writing the test class for a trigger. In my case, It would be better to check the debug log before assuming any cause for this error.

DomSFDomSF

HI All,

 

Two year down the line this still seems to be an issue,

 

All knowledge articles encountered aren't giving much insight.

 

Dose someone know how to get the relevant ProductEntry ID,

 

In this case my product is active, yet  I am getting the same error message.

 

I think I would already be happy with guidance on how to generate the Pricebook entry ID...

 

there is one post I found but hits shows only partially how to do it..

see below:

Can someone advise on how to get the PricebookEntryID?

 

Step 4 (optional)
INSERT products into "OpportunitiesLineItem" Table

1. Data Columns:
-Opportunity ID
-PricebookEntryID
-Total Price
-Quantity
-Unit price
-other fields as needed
NOTE: The Opportunity Product Table provides the "ProductID" as a mappable field, however this field should not be mapped in this process.

1. Export the Opportunity Product (OpportunityLineItem) table for a template
2. Export the appropriate Opportunities from the data loader with filter criteria.
3. Copy OpportunityID into the insert/update template file.
4. Export the "Price Book Entry" table from the data loader, the "ID" column is the PricebookEntryID.
5. Copy the appropriate PricebookEntryID's (with corresponding Opportunities) into the insert/update file.
6. Add the other data into the relevant columns in the insert/update file.
7. Open AppExchange Data Loader.
8. Insert to "Opportunity Product (OpportunityLineItem)" table

_______________________________________________________________________________________________

NOTES:
- The PricebookEntryID used in the insert file must correspond to the Opportunity Price Book that has been selected in the application.
- If you change the Product Family as a part of the update process, be sure to change the picklist values for this standard field as well.
- When loading new products and Price Books, pay particular attention to the sequence of steps detailed above. The user defined standard Price Book must contain all products before the products can be assigned to other Price Books.

ADDITIONAL REFERENCE:

1. Use Link: http://www.sforce.com/us/docs/sforce60/wwhelp/wwhimpl/js/html/wwhelp.htm
2. From the Table of Contents | Entity Relationships Diagrams | Product and Schedule objectspdf

How can you view the Opportunity Line Item ID and the Pricebook ID on an Opportunity with Product report?

https://help.salesforce.com/apex/HTViewSolution?urlname=How-can-you-view-the-Opportunity-Line-Item-ID-and-the-Pricebook-ID-on-an-Opportunity-with-Product-report-1327109401509&language=en_US

 

thsfthsf
The key for me to get things to work was to specify a "TotalQuantity" on the "OpportunityLineItem"... It seems to me that the minimum fields that need to be specified are as follows:
  • OpportunityId
  • PricebookEntryId
  • Quantity
  • TotalPrice
Please note that I had already assigned a pricebook to the opportunity.  Yet, for some reason or another it required me to manually calculate the "TotalPrice" in order to save the line item.
Roger WickiRoger Wicki
@thsf: Seriously? That's weird...

For me it was a pretty obvious problem in the end... I ended up passing on a string instead of an ID to the PricebookEntryId field... I'd rather have suspected an "INVALID_TYPE" kind of error instead of this one. But Salesforce is not the best at error messages ;)
IT Main OneIT Main One
You will get this error if the if the Product (OpportunityLineItem.Product2Id) referenced in the OpportunityLineItem has not been added to a Pricebook and that Pricebook (Opportunity.Pricebook2Id)  has been selected on the Opportunity to which you are adding the OpportunityLineItem.
Shraddha GangurdeShraddha Gangurde
@IT Main One , thank you so much. It works fine now
VonveeVonvee
For about 20 minutes I messed with this b/c I knew my product, pricebook, entry, and required fields were all correct.  But this tripped me up --> 
and that Pricebook (Opportunity.Pricebook2Id)  has been selected on the Opportunity to which you are adding the OpportunityLineItem
<-- even though it's obvious in hindsight.  

Thanks.  Thumbs up.

IT Main One
You will get this error if the if the Product (OpportunityLineItem.Product2Id) referenced in the OpportunityLineItem has not been added to a Pricebook 

 
Suman JaiswalSuman Jaiswal
Even I was getting the same error but then I changed the UnitPrice of OpportunityLineItem with PriceBookEntry UnitPrice.
Earlier my code was like this:
 OpportunityLineItem cartRecord = new OpportunityLineItem();
        cartRecord.OpportunityId = opp.id;
        cartRecord.Product2Id = prod.id;
        cartRecord.PricebookEntryId = pbe.id;
        cartRecord.UnitPrice = 34;
        cartRecord.Quantity = 221;
And then I resolve my issue with this code:
 OpportunityLineItem cartRecord = new OpportunityLineItem();
        cartRecord.OpportunityId = opp.id;
        cartRecord.Product2Id = prod.id;
        cartRecord.PricebookEntryId = pbe.id;
        cartRecord.UnitPrice = pbe.UnitPrice;
        cartRecord.Quantity = 221;