public function TestRestClient::objectUpsert in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 src/Tests/TestRestClient.php \Drupal\salesforce\Tests\TestRestClient::objectUpsert()
- 8.3 src/Tests/TestRestClient.php \Drupal\salesforce\Tests\TestRestClient::objectUpsert()
Create new records or update existing records.
The new records or updated records are based on the value of the specified field. If the value is not unique, REST API returns a 300 response with the list of matching records and throws an Exception.
Parameters
string $name: Object type name, E.g., Contact, Account.
string $key: The field to check if this record should be created or updated.
string $value: The value for this record of the field specified for $key.
array $params: Values of the fields to set for the object.
Return value
\Drupal\salesforce\SFID The new object's SFID, if created. NULL if updated. This is not ideal, but this is how Salesforce's API works. Go upvote this idea to fix it:
Overrides RestClient::objectUpsert
File
- src/
Tests/ TestRestClient.php, line 137
Class
- TestRestClient
- Test Salesforce REST client.
Namespace
Drupal\salesforce\TestsCode
public function objectUpsert($name, $key, $value, array $params) {
$random = new Random();
return new SFID(strtoupper($random
->string(SFID::MAX_LENGTH)));
}