function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ExpoExpo 

Using External ID's in API calls

Please confirm if we can create and assign tasks to an existing Account in Salesforce.com using API calls and by referencing only the External ID's in such call and not any of the Salesforce.com ID's like Account ID 

 

Based on the example provided below it appears to be possible, but I would like to have it confirmed as I am not familiar with Salesforce.com API's.

 

public void upsertForeignKeySample()
{
  Opportunity upsertOpportunity = new Opportunity();
  upsertOpportunity.setStageName("Prospecting");
  //To indicate the reference, attach an Account object, 
  //which has only the external ID field specified.
  Account upsertParentAccountRef = new Account();
  upsertParentAccountRef.setExternal_SAP1_ACCTID__c("SAP111111"); 
  upsertOpportunity.setAccount(upsertParentAccount);
  //Set the external ID for the Opportunity
  upsertOpportunity.set_SAP1_OPPID__c("SAP222222"); 
  UpsertResult[] upsertResults = binding.upsert("SAP1_OPPID__c", 
            new SObject[] {upsertOpportunity});
  // check results and do more processing after the upsert call ...
}
Message Edited by Expo on 09-22-2009 04:13 AM
SuperfellSuperfell
Yes, it should be possible.