I've read a lot about upserting into Salesforce using the API, though it seems to get a strict on what fields you can use as the 'primary key' when upserting. Salesforce asks that you use an ExternalIDField, which must be a custom field and you must specify it inside salesforce. Well thats not much use and I don't really have time to fix this. Instead you can use the lookupid attribute of default fields. this means, in effect that you could do a call like this:
salesforce.sObject[] objList;
salesforce.Contact connyhuq = new salesforce.Contact();
connyhuq.Title = "Ms.";
connyhuq.HEAPS_Interest__c = "Yes";
connyhuq.Email = "chuq@huqqers.org.uk";
connyhuq.LastName = "Kemp";
objList = new salesforce.sObject[] { connyhuq };
salesforce.UpsertResult[] upResult = binding.writeData("Email", objList);
What we have done is made the Email address the primary key on this upsert. I wish to make the Id of the object the key field but it complains that we do not have access rights to change this. I doubt there is anything you can do about this. So then I decided to try and composite key the fields and create a unqiue key for each entry, I don't have any good externalIDfields yet. However, the upsert routine only lets you use one field. Looks like I need to go into Salesforce to create the composite key field manually.
Subscribe to:
Post Comments (Atom)
I haven't run into this limitation.
ReplyDeleteI'm using the php toolkit (don't think that should matter for SOAP) and API version 13, and whenever I upsert I call it like $soapclient->upsert('Id', objectList);
'Id' is the primary key for 90% of objects, especially out of the box objects like Contact.
In the example above, is "binding" your C# SOAP client?
binding is my custom written code that hooks in with the SForce upsert function. Problem with using Id is that if it doesn't have a value specified you want to insert and Salesforce to create a new Id, it seems to break on that part for me.
ReplyDelete