0

I am currently working on a tool that manipulates various custom files, and merges the data into local C#.net lists. Once I have traversed these files I am creating records and uploading to SalesForce. As the title suggests, I am using C#.net and have followed the API reference (created a web reference in Visual Studio) etc.

Everything is working fine based on insert operation - awesome! However, as this tool will be run periodically, and I don't want duplicates in SalesForce I am trying to Upsert records to SalesForce.

I have set CustomerReference__pc as an external ID, and the field is also set to Unique.

If you are upserting a record for an object that has the External ID attribute selected but not the Unique attribute selected, (a non-unique index) your client application must have the permission “View All Data” to execute this call. (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_upsert.htm)

However, I keep getting an error message, saying that I have not set an external ID or the field is not unique.

Is this a problem/limitation because I am using person accounts?

Source Code

   foreach (var Xrecord in CustomerCSVRecords)
{
   MyList.Add(new Account
                                {
                                    FirstName = Xrecord.Forename,
                                    LastName = Xrecord.Surname,
                                    PersonBirthdate = Xrecord.DOB,
                                    RecordTypeId = recordTypeIds["B2B Customer"],
                                    CustomerReference__pc = Xrecord.CRC
                                });
}

var myArray = myList.toArray();

var results = SalesForceBinding.upsert("CustomerReference__pc", myArray);

Error Message

Additional information: INVALID_FIELD: Field name provided, CustomerReference__pc does not match an External ID, Salesforce Id, or indexed field for Account

3

It looks like the problem has to do with which object holds the external ID field. When you're dealing with person accounts via the API, you only have access to the external ID fields on the Account object, not Contact. It's explained in the 'Implementing Person Accounts' guide here (specifically with reference to the Dataloader, but applicable to the API in general).

Only account custom fields with the “External ID” attribute are available for this step. While all custom contact fields are available on person account page layouts, custom contact fields with the “External ID” attribute are not available as matching fields during person account import.

  • Thank You - like you have said, and also like the attachment says, its a limitation of Person Accounts so my external ID field cannot be on contact, it has to be on Account. – developer__c Apr 22 '15 at 8:49

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.