@Mike
I used your code to try to create a record. I slightly modified the array and the object type.
PHP Code:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
require_once ('./includes/soapclient/SforcePartnerClient.php');
require_once ('./includes/soapclient/SforceHeaderOptions.php');
$mystuff = array('Username' => 'user@email.com', // change this to a valid email
'LastName' => 'Wiley',
'FirstName' => 'Mike',
'Email' => 'user@email.com', // change this to a valid email
'Alias' => 'MWile',
'IsActive' => 'true',
'TimeZoneSidKey' => 'America/New_York',
'LocaleSidKey' => 'en_US',
'EmailEncodingKey' => 'ISO-8859-1',
'ProfileId' => '00550000000wI2LAAU',
'LanguageLocaleKey'=> 'en_US');
//clean User to allow changing of characters to XML
$mystuff = array_map('htmlspecialchars', $mystuff);
//try to add User from from array
try
{
//salesforce login and wsdl
$wsdl = './includes/soapclient/partner.wsdl.xml';
$userName = "email@gmail.com";
$password = "somepassword";
//connect to salesforce
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$loginResult = $client->login($userName, $password);
$sObject = new sObject();
$sObject->type = 'User';
$sObject->fields = $mystuff;
//this part adds the contact to salesforce
$result = $client->create(array($sObject));
if ($result->success)
{
echo "New User has been added to your instance of Salesforce with an Id of " . $result->id . "<br />";
echo "**************** ALL DONE ****************<br />";
exit;
}
else
{
//print "Unsucessful Create<br>";
$errMessage = $result->errors->message;
echo $errMessage;
}
}
catch (exception $e)
{
// This is reached if there is a major problem in the data or with
// the salesforce.com connection. Normal data errors are caught by
// salesforce.com
echo '<pre>' . print_r($e, true) . '</pre>';
return false;
exit;
}
?>
I get this error:
invalid cross reference id
have any ideas how to fix this error?
Bookmarks