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

Setting lookup fields by external id in PHP with Partner API help
Has anyone tried setting a lookup field by external ID in PHP using the partner API. Here's a code snippet of what we're trying to do but when the upsert/update is called, it just hangs our app. We tried both the field name (returns an error saying it's the wrong type) and the relationship name to no avail. When using the relationship name, no exception is thrown, no return code is given, it just hangs. Any ideas?
$messageObject = new SObject(); $messageObject->type = 'Message__c'; $messageObject->fields['External_ID__c'] = $data[8]; $sObject->fields['Original_Message__r'] = $messageObject;
This lead me to find a board post [1] about this same issue. Turns out that the Partner version doesn't handle converting the complex types correctly. So by updating the _convertToAny function in SforceBaseClient.php to
and then using the following client code
I was able to get it to work as expected.
[1] https://developer.salesforce.com/forums/?id=906F00000008sthIAA
All Answers
The code executes and completes successfully when we remove the lookup field from the list of fields we set for our custom object. Unfortunately once we add in the beforementioned lines of code, it just hangs at the upsert. We put exception handling and return codes around the upsert statement to no avail. Any ideas?
Country__c object
Employee__c object
PHP Code
This lead me to find a board post [1] about this same issue. Turns out that the Partner version doesn't handle converting the complex types correctly. So by updating the _convertToAny function in SforceBaseClient.php to
and then using the following client code
I was able to get it to work as expected.
[1] https://developer.salesforce.com/forums/?id=906F00000008sthIAA