4

Is it possible to upsert PBE records? According to the API document, upsert is a supported function. Now that we can create custom fields on the PBE, I even added an external ID field, but I cannot seem to get this to work. When I try to upsert, using the external ID field, I get this error "This price definition already exists in this price book".

  • Hello Jim. Which PBE fields are you trying to set in your upsert call? I've seen issues in the past where some fields can cause an issue depending on whether or not the upsert call ends up being an insert vs. update. – Chris Noe Apr 30 '15 at 18:10
  • Hey Chris. I am doing a true upsert, so I am passing all of the fields: ProductID, PricebookID, currencyisocode and Price, along with my custom external ID field – JimRae Apr 30 '15 at 18:19
6

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.

| improve this answer | |
  • @JimRae and Chris .... n.b. if you need to reassociate a PBE to a different currencyIsoCode or pricebook or product, you will need to delete it and re-insert. Noter also that if a custom pricebook, the equivalent PBE for the standardpricebook must already exist – cropredy Apr 30 '15 at 18:59
  • fantastic, we just hit this snag and did not have a workaround until now, thanks! – greenstork Apr 30 '15 at 19:26
  • 1
    That worked great @chris! I am just doing 2 upserts, one with all of the fields (to get my new records in) and a second that just uses my external ID and only updates the price and the "isActive" fields (the only ones that can be updated). – JimRae Apr 30 '15 at 19:59
0

You can anytime create an External ID in Pricebookentry and Create/Update using same set of field values. No need to remove Product / PB / Currency ISO Code.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.