You need to sign in to do that
Don't have an account?
Bobbin
echo "**** Creating the following:\r\n";
$createResponse = $mySforceConnection->create($sObject, 'Case');
create function issue
New to salesforce *blush* My customer requires I provide a query/insert/update class to interface with salesforce data via their API, rather than their existing mix of API+Web-To-Case.
My first stop was to use a PHP sample to see how the pieces fit. Please someone advise if they can see where I've gone wrong. Also, is it correct to refer to custom fields as I have in my code example below the results?
Unfortunately I get the following result:
-----------------------------------------------------------
**** Creating the following:
Notice: Undefined property: stdClass::$result in /var/www/digiweb01/improved/include/soapclient/SforceBaseClient.php on line 399
Warning: Invalid argument supplied for foreach() in /var/www/digiweb01/improved/include/test.php on line 50
**** Now for Delete:
Notice: Undefined property: stdClass::$result in /var/www/digiweb01/improved/include/soapclient/SforceBaseClient.php on line 481
**** Now for UnDelete: 440500D200000001phK!AQcAQIW1c7e_WBmJ43xOQ.GloMvrcZk5I_2apGPNEvF5Og9FhAFuCneyaDAoEK8QmaeDlCu2_unMey9i5PEFv4jBbrzMUVF0 MISSING_ARGUMENT: undelete called with a batch of 0 ids to undelete; must specify at least 1 id
Notice: Undefined property: stdClass::$result in /var/www/digiweb01/improved/include/soapclient/SforceBaseClient.php on line 399
Warning: Invalid argument supplied for foreach() in /var/www/digiweb01/improved/include/test.php on line 50
**** Now for Delete:
Notice: Undefined property: stdClass::$result in /var/www/digiweb01/improved/include/soapclient/SforceBaseClient.php on line 481
**** Now for UnDelete: 440500D200000001phK!AQcAQIW1c7e_WBmJ43xOQ.GloMvrcZk5I_2apGPNEvF5Og9FhAFuCneyaDAoEK8QmaeDlCu2_unMey9i5PEFv4jBbrzMUVF0 MISSING_ARGUMENT: undelete called with a batch of 0 ids to undelete; must specify at least 1 id
-----------------------------------------------------------
Code:
-----------------------------------------------------------
<?
error_reporting(E_ALL);
ini_set("soap.wsdl_cache_enabled", "0");
define("SOAP_CLIENT_BASEDIR", "soapclient");
include_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
include_once("constants.php");
error_reporting(E_ALL);
ini_set("soap.wsdl_cache_enabled", "0");
define("SOAP_CLIENT_BASEDIR", "soapclient");
include_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
include_once("constants.php");
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login(SF_USER, SF_PASS);
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login(SF_USER, SF_PASS);
$description = "Request for User Registration: \n\n"
."Company Name: \nTest Company\n\n"
."User Name: Ryan Cauchi-Mills\n\n"
."Email Address: ryan@intercityurgent.co.nz\n\n";
."Company Name: \nTest Company\n\n"
."User Name: Ryan Cauchi-Mills\n\n"
."Email Address: ryan@intercityurgent.co.nz\n\n";
$sObject = new stdclass();
$sObject->origin = 'MoBiz';
$sObject->recordType = '012200000004v5q';
$sObject->MoBiz_User_Last_Name__c = 'Cauchi-Mills';
$sObject->MoBizUserName__c = 'Ryan';
$sObject->Company_Name__c = 'Test Company';
$sObject->MoBiz_User_Id__c = 'useridformobiz';
$sObject->type = 'MoBiz';
$sObject->email = 'ryan@intercityurgent.co.nz';
$sObject->subject = 'MoBiz Registration Request';
$sObject->description = $description;
$sObject->origin = 'MoBiz';
$sObject->recordType = '012200000004v5q';
$sObject->MoBiz_User_Last_Name__c = 'Cauchi-Mills';
$sObject->MoBizUserName__c = 'Ryan';
$sObject->Company_Name__c = 'Test Company';
$sObject->MoBiz_User_Id__c = 'useridformobiz';
$sObject->type = 'MoBiz';
$sObject->email = 'ryan@intercityurgent.co.nz';
$sObject->subject = 'MoBiz Registration Request';
$sObject->description = $description;
echo "**** Creating the following:\r\n";
$createResponse = $mySforceConnection->create($sObject, 'Case');
$ids = array();
foreach ($createResponse as $createResult) {
print_r($createResult);
array_push($ids, $createResult->id);
}
echo "**** Now for Delete:\r\n";
$deleteResult = $mySforceConnection->delete($ids);
print_r($deleteResult);
foreach ($createResponse as $createResult) {
print_r($createResult);
array_push($ids, $createResult->id);
}
echo "**** Now for Delete:\r\n";
$deleteResult = $mySforceConnection->delete($ids);
print_r($deleteResult);
echo "**** Now for UnDelete:\r\n";
$deleteResult = $mySforceConnection->undelete($ids);
print_r($deleteResult);
$deleteResult = $mySforceConnection->undelete($ids);
print_r($deleteResult);
} catch (Exception $e) {
echo $mySforceConnection->getLastRequest();
echo $e->faultstring;
}
echo $mySforceConnection->getLastRequest();
echo $e->faultstring;
}
?>
Bobbin
Code: