library convey-sugar
Extensions for SugarCRM to more easily and flexibly manipulate data
warent/convey-sugar
Extensions for SugarCRM to more easily and flexibly manipulate data
- Sunday, July 17, 2016
- by warent
- Repository
- 1 Watchers
- 0 Stars
- 8 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 0 % Grown
ConveySugar
License: MIT, (*1)
1. About
- Designed to work with SugarCRM 7 and the v10 REST API
2. Installation
ConveySugar is available via Composer
$ composer require warent/convey-sugar, (*2)
3. Usage Examples
sugar = new Sugar([
'SUGAR_URL' => 'https://sugar/rest/v10/',
'SUGAR_USERNAME' => 'admin',
'SUGAR_PASSWORD' => 'password'
]);
}
public function searchContacts() {
// Instantiating a new Sugar Utility
// This one cycles through all records within a Sugar module
$serchUtil = new Search(['resultsFn' => function($params) {
$resultCount = count($params['results']);
echo "$resultCount results from offset {$params['offset']}";
foreach ($params['results'] as $result) {
print_r($Result);
}
});
// We execute our Search Utility on the module 'Contacts'
$this->sugar->execute('Contacts', $searchUtil);
}
}
?>
4. Utilities
Count
Description
Return the number of records within a sugar module
Parameters
Delete
Description
Delete a record by ID
Parameters
- recordID (Sugar ID [string]) Required
Insert
Description
Insert a new record
Parameters
- values (Assoc Array) Required
Description
Cycle related records of one sugar record to another module
Parameters
- recordID (Sugar ID [string]) Required
- relation (Sugar Module [string]) Required
- type (Related::Type [static int])
- Related::TYPE_NORMAL
- Related::TYPE_NAKED
- Related::TYPE_BACK
- number (Integer)
- transform (Related::Transform [static int])
- Related::TRANSFORM_JSON
- Related::TRANSFORM_BOOL
- resultsFn (Function)
- Parameters (Assoc Array)
- results (Array)
- offset (Integer)
- offset (Integer)
- limit (Integer)
Search
Description
Cycle records of a sugar module
Parameters
- resultsFn (Function) Required
- Parameters (Assoc Array)
- results (Array)
- offset (Integer)
- offset (Integer)
- limit (Integer)
resultsFn
- Returning
false in a resultsFn will stop/break the lookup
-
transform will return JSON (Assoc Array) by default. TYPE_BOOL will return true if any results are found, otherwise return false
-
type refers to theSugarCRM formatting of relational queries. There are three (unofficial) known ways for this to happen in the Sugar API, NORMAL, BACK, and NAKED: in a NORMAL type the query is $module_$relation_$number; in a BACK type the query is $relation_$module_$number; in a NAKED type the query is simply $relation. NORMAL is the default type and 1 is the default number as these are the most common configurations.
Thank you
dev-master
9999999-dev
Extensions for SugarCRM to more easily and flexibly manipulate data
Sources
Download
The Requires
by
Wyatt Arent