public function SalesforceCommands::createObject in Salesforce Suite 8.4
Same name and namespace in other branches
- 8.3 src/Commands/SalesforceCommands.php \Drupal\salesforce\Commands\SalesforceCommands::createObject()
- 5.0.x src/Commands/SalesforceCommands.php \Drupal\salesforce\Commands\SalesforceCommands::createObject()
Create an object with specified data.
@option encoding Format to parse the object. Use "json" for JSON (default) or "query" for data formatted like a query string, e.g. 'Company=Foo&LastName=Bar'. Defaults to "query".
@field-labels status: Status id: Id errors: Errors @default-fields status,id,errors
@command salesforce:create-object @aliases sfco,sf-create-object
Parameters
string $object: The object type name in Salesforce (e.g. Account).
mixed $data: The data to use when creating the object (default is JSON format). Use '-' to read the data from STDIN.
array $options: An associative array of options whose values come from cli, aliases, config, etc.
Return value
\Consolidation\OutputFormatters\StructuredData\PropertyList The create() response.
File
- src/
Commands/ SalesforceCommands.php, line 564
Class
- SalesforceCommands
- A Drush commandfile.
Namespace
Drupal\salesforce\CommandsCode
public function createObject($object, $data, array $options = [
'encoding' => 'query',
]) {
try {
$result = $this->client
->objectCreate($object, $data);
return new PropertyList([
'status' => 'Success',
'id' => (string) $result,
'errors' => '',
]);
} catch (RestException $e) {
return new PropertyList([
'status' => 'Fail',
'id' => '',
'errors' => $e
->getMessage(),
]);
}
}