function drush_salesforce_sf_create_object in Salesforce Suite 7.3
Same name and namespace in other branches
- 8.4 salesforce.drush.inc \drush_salesforce_sf_create_object()
- 8.3 salesforce.drush.inc \drush_salesforce_sf_create_object()
- 5.0.x salesforce.drush.inc \drush_salesforce_sf_create_object()
Create a Salesforce object available to the logged-in user.
Parameters
$name: The object type name, e.g. Account
$data: The object data, or '-' to read from stdin
File
- ./
salesforce.drush.inc, line 281 - Drush integration for Salesforce.
Code
function drush_salesforce_sf_create_object($name, $data) {
if ($data == '-') {
$data = stream_get_contents(STDIN);
}
$format = drush_get_option('format', 'json');
$params = array();
switch ($format) {
case 'query':
parse_str($data, $params);
break;
case 'json':
$params = json_decode($data, TRUE);
break;
default:
drush_log(dt('Invalid format'), 'error');
return;
}
$salesforce = _drush_salesforce_drush_get_api();
try {
if ($result = $salesforce
->objectCreate($name, $params)) {
drush_print_r($result);
}
} catch (SalesforceException $e) {
drush_log($e
->getMessage(), 'error');
}
}