4

I am writing a script to run on a schedule to automatically import data from our accounting software into salesforce using their API. I cannot find a good way to upsert objects with many to many relationships.

Right now I have to upsert the related objects separately and then clear all the join objects and create new ones. My goal is to be able to bulk upload the first related objects and then bulk upload the second related objects with their relationships to the first objects and have the join objects set up correctly without duplicates from that.

A middle ground workaround I am doing is to setup an external id field on the join object. For the external id I am using text made up of the combined external id from the first object and the external id from the second object.

With that I will now upsert the join objects for the relationship rather than deleting them all then creating or checking if it exists and creating if not for each.

Does anyone know of a better way to handle this?

Your Answer

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

Browse other questions tagged or ask your own question.