Пример #1
0
 }
 echo "<br/>Retrieve the newly created records:<br/><br/>\n";
 $response = $mySforceConnection->retrieve('Id, FirstName, LastName, Phone', 'Contact', $ids);
 foreach ($response as $record) {
     echo $record->Id . ": " . $record->fields->FirstName . " " . $record->fields->LastName . " " . $record->fields->Phone . "<br/>\n";
 }
 echo "<br/>Next, update the new records<br/><br/>\n";
 $records[0] = new SObject();
 $records[0]->Id = $ids[0];
 $records[0]->fields = array('Phone' => '(415) 555-5555');
 $records[0]->type = 'Contact';
 $records[1] = new SObject();
 $records[1]->Id = $ids[0];
 $records[1]->fields = array('Phone' => '(415) 486-9969');
 $records[1]->type = 'Contact';
 $response = $mySforceConnection->update($records);
 foreach ($response as $result) {
     echo $result->success == 1 ? $result->id . " updated<br/>\n" : "Error: " . $result->errors->message . "<br/>\n";
 }
 echo "<br/>Retrieve the updated records to check the update:<br/><br/>\n";
 $response = $mySforceConnection->retrieve('Id, FirstName, LastName, Phone', 'Contact', $ids);
 foreach ($response as $record) {
     echo $record->Id . ": " . $record->fields->FirstName . " " . $record->fields->LastName . " " . $record->fields->Phone . "<br/>\n";
 }
 echo "<br/>Let's remove those phone numbers<br/><br/>\n";
 $records[0] = new SObject();
 $records[0]->Id = $ids[0];
 $records[0]->fieldsToNull = 'Phone';
 $records[0]->type = 'Contact';
 $records[1] = new SObject();
 $records[1]->Id = $ids[1];