I am using SalesforceSharp to create an Opportunity. The header is working OK, I have ensured that the CurrencyIsoCode and PriceBook2Id fields are set.

When trying to create the Opportunity Line Item, I am getting the error message below:

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

When creating the object I am passing in the OpportunityId, PriceBookEntryId, and Quantity. I have tried various combinations of using Product2Id, and also using Product Code and Total Price.

I have checked that the Opportunity has a valid Price Book connected, and can create the item manually.

If I change to pass the Product2Id in, I get a different error message:

field integrity exception: PricebookEntryId (pricebook entry currency code does not match opportunity currency code)

I have four entries in my Price Book for the same product with different currencies. I have found that if I select them using the Developer Console, the JPY entry is first. And looking at a validation rule in the Logs I can see that it indeed is finding the JPY entry.


  1. Approach 1, when it is referring to v3 - v3 of what?
  2. Approach 2, what field am I missing on the Opportunity Line for it to find the correct PriceBook entry?
  • I've no experience with C#, but "v3" is likely referring to the Salesforce API version. A quick dive through the SalesforceSharp codebase reveals that they use v28.0 by default (which is 8 years old at this point, the newest API version is 52.0). Do you ever set/change the value of SalesforceClient.ApiVersion?
    – Derek F
    May 26, 2021 at 12:26
  • The version is set to match my sandbox which is currently at v51. May 26, 2021 at 12:35
  • 2
    Does this answer your question? Pricebook entry currency code does not match opportunity currency code
    – identigral
    May 26, 2021 at 14:55
  • No i reviewed that and it looks like they were creating the price book entry in code. In my scenario i am pointing to an existing price book entry. May 26, 2021 at 15:08
  • Same idea for existing - you need to retrieve the correct PricebookEntry record based on your target opp's currency and product (Product2). Mismatch leads to the error message you've encountered.
    – identigral
    May 26, 2021 at 15:32


You must log in to answer this question.

Browse other questions tagged .