1

I am trying to create a record in Salesforce Enterprise but I get an error message.

The code:

<?php

define("SOAP_CLIENT_BASEDIR", "soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once ('userAuth.php');

try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

$sObject1 = new stdclass();
$sObject1->number__c = '20';
$sObject1->name__c = 'testupdateCity';
$sObject1->country__c = 'US';

$response = $mySforceConnection->update(array ($sObject1), 'nisaion_01__c');

print_r($response);

} catch (Exception $e) {
print_r($mySforceConnection->getLastRequest());
echo $e->faultstring;
}
?>

The error:

Array ( [0] => stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => Id not specified in an update call [statusCode] => MISSING_ARGUMENT ) ) [id] => [success] => ) )

2 Answers 2

0

Or you can use UPSERT call.

$response = $mySforceConnection->upsert(array ($sObject1), 'nisaion_01__c');

When you can UPDATE call, the ID field is required to uniquely identify which record to update.

1

welcome to the salesforce stack exchange community!

The problem is that you are using the wrong keyword to create a new record in salesforce.

You have to replace the keyword update with create in the following line:

$response = $mySforceConnection->update(array ($sObject1), 'nisaion_01__c');

The result

$response = $mySforceConnection->create(array ($sObject1), 'nisaion_01__c');
1
  • Thanks, Christian. The Update works fine. The "create" works but creates 3 records on each submit. Any Ideas? Thanks. David. Commented Dec 24, 2014 at 13:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .