You need to sign in to do that
Don't have an account?

Unable to get foreign key to work with partner wsdl and upsert
$sObject = new sObject();
$sObject->type = 'Object1__c';
$sObject->fields['Data1__c'] = $data[1];
$sObject->fields['ExternalId__c'] = $data[2];
$sObjects[] = $sObject;
$status = upsert($mySforceConnection,$sObjects);
This works correctly. I then try to introduce a foreign key and everything fails.
$sObject = new sObject();
$sObject->type = 'Object1__c';
$sObject->fields['Data1__c'] = $data[1];
$sObject->fields['ExternalId__c'] = $data[2];
$key = new sObject();
$key->type = 'Subscription__c';
$key->fields['buying_email_address__c'] = $data[0];
$sObject->fields['Subscription__r'] = $key;
$sObjects[] = $sObject;
$status = upsert($mySforceConnection,$sObjects);
The field subscription__c has a foreign key relationshipship with object1__c and is named subscription__r.
I get the error Catchable fatal error: Object of class SObject could not be converted to string in...
I know this is probably very simple, but not seeing it.
As a workaround, I simply pass the xml equivalent
"<type>Subscription__c</type><buying_email_address__c>$data[0]</buying_email_address__c>