Skip to content

Instantly share code, notes, and snippets.

@esimonetti
Created June 14, 2014 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esimonetti/5d2ea71a90283bbd9c11 to your computer and use it in GitHub Desktop.
Save esimonetti/5d2ea71a90283bbd9c11 to your computer and use it in GitHub Desktop.
Retrieve count of New Cases from a SugarCRM v7 system and format output as: {"open_cases":"XXX"}
{
"require": {
"spinegar/sugar7wrapper": "dev-master"
},
"minimum-stability": "dev"
}
<?php
require_once('vendor/autoload.php');
// SugarCRM Details
$sugar_url = 'https://your-sugarcrm-url.com/rest/v10/';
$sugar_user = 'your_user';
$sugar_password = 'your_password';
// End SugarCRM Details
$sugar = new \Spinegar\Sugar7Wrapper\Rest();
$sugar->setUrl($sugar_url)->setUsername($sugar_user)->setPassword($sugar_password)->connect();
// count new cases records
$cases = $sugar->countRecords('Cases',
array(
'filter' => array(
array('status' => 'New'),
),
)
);
if(!empty($cases))
{
echo json_encode(
array(
'open_cases' => $cases['record_count']
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment