Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.