Im trying to understand how to use upsert.. for example there`s :

ID = 1600.

Type = Shipping To.


ID = 1600. Type = Billing to.

Can I use upsert to update record where ID = 1600 and type = shipping.. and insert new record with ID = 1600 and type = Billing to, if record with "billing to" doesnt exist?


2 Answers 2


With the same recordId = 1600, if you perform upsert then it will only update the existing record and not new record will be created.

Your use case can be solved in the following way.

  1. Create an External Id field and populate the external id field value with a combination of Id + type.

  2. Now based on this External Id field you can perform upsert operation. In that scenario, existing record Id = 1600 with type = Shipping To will get updated and new record Id = 1600 with type = Billing to gets inserted.

  3. Since, External Id is new field, so you need to perform a data migration to populate this field value for historical records.


If both records have the same ID only the last operation's changes will be reflected once the upsert is complete. If you want a new record inserted you need to include the data for that record with a new, unique record ID in your upsert file.

Here is somewhere to start for understanding record IDs.

How does "upsert" work?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .