Can I upsert PricebookEntry Records?
I ran into a similar challenge on a previous project where existing PBE rows could not be "updated" if you are sending CurrencyIsoCode, Product2Id, or Pricebook2Id as part of your upsert call. If you look at the API guide, the updateable flag on those three fields is false. The workaround I implemented was as follows:
- Run initial upsert call with all fields on PBE. Existing records will error out because CurrencyIsoCode, Product2Id, and Pricebook2Id are not updateable fields. New records will insert correctly.
- Run the same upsert again but remove CurrencyIsoCode, Pricebook2Id, and Product2Id fields from your upsert call. This will allow the failed records from the first upsert call to be updated appropriately.
It's not the ideal workaround because you are essentially doubling your API calls but it worked well for what we needed.