+ Start a Discussion
steven.warrensteven.warren 

Using partner WSDL to upsert foreign key relationship on custom object

Hi, I am able to upsert a contact record referencing the external field of its account relationship. But if I try to do that with a custom table I get the following error:

"Unexpected element {}type during simple type deserialization"

Does anyone have any experience or insight into this issue? Here's the code fragment in question:

Code:
    ArrayList elements = new ArrayList();

    elements.add(new MessageElement(new QName("SPS_Account_ID__c"), id));

    // Foreign key relationship to the Account object
    MessageElement client_me = new MessageElement(new QName("Account__c"));
    client_me.addChild(new MessageElement(new QName("type"), "Account"));
    client_me.addChild(new MessageElement(new QName("Client_ID__c"),  accountID));
    elements.add(client_me);

    SObject[] sObjects = new SObject[1];
    sObjects[0] = new SObject();
    sObjects[0].setType("SPS_Account__c");
    sObjects[0].set_any((MessageElement[]) elements.toArray(new MessageElement[elements.size()]));



Message Edited by steven.warren on 04-08-2008 04:45 PM
SuperfellSuperfell
You need to use the relationship name, not the field name, you set your child sobject structure on the account__c field, but that's an Id field, it should be set on the account relationship, account__r
steven.warrensteven.warren
Worked great! Thanks for the quick response. :smileyhappy:
RamanaRamana

Hello Steven,

 

Can you please give me the code snippet to upsert foreign key relationship on an object using Partner WSDL

(may be using Account and Contact)?

 

Regards,

Ramana Maddikunta 

kmadminkmadmin

Simon,

 

Can you point me to a c# solution for partner wsdl that uses external ID of parent to insert child object?