
8 个回答
So you have a collection of records that you want to send updates to Salesforce for. Some of them may exist in Salesforce already with the External ID field set. Some of them won't?If, as you say, you don't have the Salesforce ID or another way in you local system to identify which records are already in Salesforce, you would need to do a SOQL query first to identifiy which External Ids existing in Salesforce. I.e.
- Get the list of all the External IDs you want to update
- Do a SOQL query to Salesforce to see which of those records exist in Salesforce already
- Only do the upsert for the records that are already in Salesforce (by this stage you could also do an update() as the SOQL query could bring back the Salesforce ID)
Again, as you say, if you can add the Salesforce ID to the local system or otherwise keep track of which records are already in Salesforce it would be more efficent in terms of Salesforce API calls.