You need to sign in to do that
Don't have an account?
LVS
Foreign keys in upsert operation
According to (www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_upsert.htm, see Rules and Guidelines section), the upsert operation supports use of External IDs in reference fields. That is, I'm inserting an Opportunity and I need to specify the related Account. However, I have only the External Id value of Account. Usually, I would query the Accout's Id, the use it to insert a new Opportunity but the Salesforce API lets you skip this step - (see http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_upsert.htm) However, I'm curious to know how this can be done via Apex code - the URL above talks about the Web Services API which is in Java or other environment code. Has anyone been able to do that? |
This Apex topic shows how to insert parent and child records by using nested objects: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_foreign_keys.htm
If your parent account records already exist, skip creating the second account in the example, and just create the opportunity.
All Answers
2nd link will be for the people who will use salesforce as an API to upsert records in to salesforce via c#, java....etc some other languages....
Yes, that's what I said. I'm looking for an Apex equivalent.
This Apex topic shows how to insert parent and child records by using nested objects: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_foreign_keys.htm
If your parent account records already exist, skip creating the second account in the example, and just create the opportunity.