Using the partner WSDL Is it possible to update the owner of an Account by passing an external id through the Account.owner field? It is my understanding that this field is actually an Id field and it's name is Account.ownerId.

User has an external id field myExternalUserId__c which takes a number.

The following returns No such column 'col' on entity 'Account' where 'col' is:


If I pass OwnerId as the element with innerText of 11 as below, then I receive

Error [MALFORMED_ID] with message "Owner ID: id value of incorrect type: 11"

The following code snippet is adapted from the developer docs.

// Create an sObject of type account
sObject upsertAccount = new sObject();
upsertAccount.type = "Account";<br/>
// Set the Phone field to a new value.
// The Phone field needs to be created as an XML element.
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement phoneField = doc.CreateElement("Phone");
phoneField.InnerText = "(414) 555-1212";
System.Xml.XmlElement externalField = doc.CreateElement("myExternalId__c");
externalField.InnerText = "externalId_abc";<br/>
// this throws an exception "INVALID_FIELD: No such column"
System.Xml.XmlElement ownerField = doc.CreateElement("OwnerId");
ownerField.InnerText = "11";<br/>
// Add the Phone field to the account
upsertAccount.Any = new System.Xml.XmlElement[] {phoneField, externalField, ownerField};<br/>
// Make the upsert call by passing an array
SaveResult[] saveResults = binding.upsert(
new sObject[] {upsertAccount});

Is there a way to update this reference given an external id using the Partner WSDL?

I'm hoping to avoid using workflows or triggers in SF to accomplish this.

1 Answer 1


I have come up with a solution after examining the QueryResult of an Account query including owner fields. All you need to do is append the sObject's fields (including the external id) as child nodes under the related sObject field.

        List<sObject> sObjects = new List<sObject> ();
        XmlDocument xDoc = new XmlDocument ();

        // Account.External_Account_ID__c
        XmlElement xElemExtId = xDoc.CreateElement ("External_Account_ID__c");
        xElemExtId.InnerText = "myExternalIdValue";

        // Account.Phone
        XmlElement xElemPhone = xDoc.CreateElement ("Phone");
        xElemPhone.InnerText = "4145552345";

        // Account.Owner
        XmlElement xElemOwner = xDoc.CreateElement ("Owner");
        // owner is of sObject type "User"
        XmlNode xElem = xDoc.CreateElement ("type");
        xElem.InnerText = "User";
        xElemOwner.AppendChild (xElem);
        // add the external id reference
        xElem = xDoc.CreateElement ("External_User_Id__c");
        xElem.InnerText = "11";
        xElemOwner.AppendChild (xElem);

        sObject owner = new sObject () {
            //Id = "",
            type = "Account",
            Any = new XmlElement[] {
            fieldsToNull = new string[] {},
        sObjects.Add (owner);

        foreach (UpsertResult result in binding.upsert("External_Account_ID__c", sObjects.ToArray())) {
            if (result.success == false) {
                foreach (var error in result.errors) {
                    Console.WriteLine (error.message);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .