Relatively new to working with the Salesforce API. Trying to create a new record for a custom object we have created in Salesforce. Below is the code I am using to create this custom object, I am making sure I am using the API names for the object itself as well as for the fields.
<?php
$username = "myusername";
$password = "mypassword";
define("SOAP_CLIENT_BASEDIR", "Force.com-Toolkit-for-PHP-master/soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login($username, $password);
$sObject = new stdclass();
$sObject->First_name__c = 'Test';
$sObject->Last_name__c = 'Test';
$sObject->Email__c = '[email protected]';
$sObject->RecordType = "MyCustomRecordType";
$sObject->Name = "API Testing";
$createResponse = $mySforceConnection->create(array($sObject), 'CustomObject__c');
} catch (Exception $e) {
var_dump($e);
echo $mySforceConnection->getLastRequest();
echo $e->faultstring;
}
?>
The error I am receiving from this code is the following:
No fields provided in an external foreign key reference in entity: RecordType
This is how the standard fields for the object looks like in Salesforce.
I made sure my RecordType name matches that of the record type configured in Salesforce.
What am I missing here? Thank you.