warent / convey-sugar
Extensions for SugarCRM to more easily and flexibly manipulate data
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/warent/convey-sugar
Requires
- spinegar/sugar7wrapper: dev-master
This package is not auto-updated.
Last update: 2025-10-26 02:09:33 UTC
README
License: MIT
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
3. Usage Examples
<?php namespace App; use ConveySugar\Sugar; use ConveySugar\Utilities\Search; class ContactSearchingApp { private $sugar; public function __construct() { // Creating our Sugar connection instance. // Connection opens when newed up, // so be sure accepting functions accept sugar by reference. $this->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
- None
Delete
Description
Delete a record by ID
Parameters
- recordID (Sugar ID [string]) Required
Insert
Description
Insert a new record
Parameters
- values (Assoc Array) Required
Related
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)
- Parameters (Assoc Array)
- offset (Integer)
- limit (Integer)
Search
Description
Cycle records of a sugar module
Parameters
- resultsFn (Function) Required
- Parameters (Assoc Array)
- results (Array)
- offset (Integer)
- Parameters (Assoc Array)
- offset (Integer)
- limit (Integer)
5. Extra Features
resultsFn
- Returning
falsein a resultsFn will stop/break the lookup
Related (Utility)
transformwill return JSON (Assoc Array) by default.TYPE_BOOLwillreturn trueif any results are found, otherwisereturn falsetyperefers to theSugarCRMformatting of relational queries. There are three (unofficial) known ways for this to happen in the Sugar API,NORMAL,BACK, andNAKED: in aNORMALtype the query is$module_$relation_$number; in aBACKtype the query is$relation_$module_$number; in aNAKEDtype the query is simply$relation.NORMALis the defaulttypeand1is the defaultnumberas these are the most common configurations.