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
SeanMSSeanMS 

Issue with External Id and Upserting multiple records

I have a C# method that uses the sforce API to upsert only one custom object record. I copied all of the detail (the setting of the object properties etc) and changed this upsert call to update multiple records instead (passing in an array of sObjects instead of one sObject). However, when I run the new method I get this error...

 

"Unable to create/update fields: External_Salesforce_ID__c. Please check the security settings of this field and verify that it is read/write for your profile."

 

INVALID_FIELD_FOR_INSERT_UPDATE

 

Why would the same code work for upserting one record but not upserting multiple records? I'm at a loss.

 

Thanks for any ideas.

 

// Original Code...
public bool UpsertCustomAccountRecord(Custom_Account__c upsertObject)
{
bool upsertSuccess = false;
sObject[] upserts = new Custom_Account__c[1];
upserts[0] = upsertObject;

UpsertResult[] upsertResult = Binding.upsert("External_Salesforce_Id", upserts);

if (upsertResult[0].success)
{
upsertSuccess = true;
}
else
{
upsertErrors = new Error[upsertResult[0].errors.Length];
upsertErrors = upsertResult[0].errors;
}
...
...


// New code...
public UpsertResult[] UpsertBatchCustomAccountRecords(List<Custom_Account__c> upsertObjects)
{
sObject[] upserts = new Custom_Account__c[upsertObjects.Count];
upserts = upsertObjects.ToArray();

UpsertResult[] upsertResults = Binding.upsert("External_Salesforce_Id", upserts);

return upsertResults;
...
...

 


Message Edited by SeanMS on 12-11-2009 11:36 AM