Sugar Developer Guide
Total Page:16
File Type:pdf, Size:1020Kb
SUGAR DEVELOPER GUIDE VERSION 6.2.0 Sugar Developer Guide – 6.2.0 Sugar Developer Guide Version 6.2.0, 2011 Copyright © 2004-2011 SugarCRM Inc. www.sugarcrm.com This document is subject to change without notice. License This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License (“License”). To view a copy of this license, visit http://www.creativecommons.org/licenses/by- nc-nd/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. Disclaimer Your Warranty, Limitations of liability and Indemnity are expressly stated in the License. Please refer to the License for the specific language governing these rights and limitations Trademarks All SugarCRM logos in this document are registered trademarks of SugarCRM Inc. See the SugarCRM trademark policies at http://www.sugarcrm.com/crm/open-source/trademark-information.html for more information on how SugarCRM trademarks can be used. 2 Table of Contents Preface ____________________________________________________________________ 10 About this Guide__________________________________________________________________ 10 Audience ________________________________________________________________________ 10 Overview ________________________________________________________________________ 10 Core Features ____________________________________________________________________ 11 Related Documentation ____________________________________________________________ 12 Chapter 1: SugarCRM Overview ________________________________________________ 13 Platform Overview ________________________________________________________________ 13 Application Framework Overview ____________________________________________________ 13 Module Framework Overview _______________________________________________________ 17 User Interface Framework Overview _________________________________________________ 20 Extension Framework Overview _____________________________________________________ 20 Sugar Dashlets Overview ___________________________________________________________ 20 Web Services Overview ____________________________________________________________ 20 Cloud Connectors/External API overview ______________________________________________ 21 Chapter 2 Application Framework _______________________________________________ 22 Entry Points _____________________________________________________________________ 22 Upgrade implications ______________________________________________________________ 22 File Caching _________________________________________________________________ 23 Sugar Dashlets ______________________________________________________________ 24 Sugar Dashlet files ________________________________________________________________ 24 Templating ______________________________________________________________________ 25 Categories _______________________________________________________________________ 25 Sugar Dashlet base class ___________________________________________________________ 25 Sugar Dashlets JavaScript ___________________________________________________________ 25 Browser JavaScript ___________________________________________________________ 26 Accessing Language Pack Strings _____________________________________________________ 26 Quicksearch _____________________________________________________________________ 26 3 ACL _______________________________________________________________________ 27 Scheduler __________________________________________________________________ 28 Databases __________________________________________________________________ 28 Indexes ____________________________________________________________________ 29 Primary Keys, Foreign Keys, and GUIDs __________________________________________ 29 Logger _____________________________________________________________________ 31 Logger Level _____________________________________________________________________ 31 Log File Name ____________________________________________________________________ 31 Log File Extension _________________________________________________________________ 31 Log File Date Format ______________________________________________________________ 31 Max Log File Size _________________________________________________________________ 32 Max Number of Log Files ___________________________________________________________ 32 Log Rotation _____________________________________________________________________ 32 Custom Loggers __________________________________________________________________ 32 Web Services ________________________________________________________________ 33 SOAP ___________________________________________________________________________ 33 REST ___________________________________________________________________________ 35 SOAP vs REST _______________________________________________________________ 37 API Definitions ______________________________________________________________ 37 Versioning _______________________________________________________________________ 38 Core Calls _______________________________________________________________________ 38 Sample Code _____________________________________________________________________ 62 Sample Request for User Login ______________________________________________________ 62 Extensibility in Upgrade Safe Manner _________________________________________________ 63 SOAP Errors _____________________________________________________________________ 64 Support WS-I 1.0 Basic profile for WSDL _______________________________________________ 65 SugarSoap Examples ______________________________________________________________ 65 Cloud Connectors Framework __________________________________________________ 65 Overview ________________________________________________________________________ 65 4 Factories ________________________________________________________________________ 66 Sources _________________________________________________________________________ 67 Formatters ______________________________________________________________________ 70 Class definitions __________________________________________________________________ 72 Chapter 3 Module Framework __________________________________________________ 77 Overview ___________________________________________________________________ 77 User Interface Framework _____________________________________________________ 77 Model-View-Controller (MVC) Overview ______________________________________________ 77 SugarCRM MVC Implementation _____________________________________________________ 78 Metadata Framework ________________________________________________________ 85 Background ______________________________________________________________________ 85 Application Metadata _____________________________________________________________ 85 Module Metadata ________________________________________________________________ 86 SearchForm Metadata _____________________________________________________________ 86 DetailView and EditView Metadata __________________________________________________ 88 SugarField Widgets ________________________________________________________________ 96 Metadata Framework Summary ____________________________________________________ 109 Formatting Changes ______________________________________________________________ 110 Vardefs ___________________________________________________________________ 110 Dictionary Array _________________________________________________________________ 110 Fields Array _____________________________________________________________________ 110 Indices Array ____________________________________________________________________ 112 Relationships Array ______________________________________________________________ 112 Many-to-Many Relationships _________________________________________________ 113 Subpanels _________________________________________________________________ 115 One-to-Many Relationships ________________________________________________________ 115 Many-to-Many Relationships ______________________________________________________ 116 Relationship Metadata ____________________________________________________________ 116 Layout Defs _____________________________________________________________________ 117 5 Shortcuts __________________________________________________________________ 117 TimeDate 2.0 ______________________________________________________________ 118 Design goals: ____________________________________________________________________ 118 Terms _________________________________________________________________________ 118 Implementation _________________________________________________________________ 118 Compatibility ___________________________________________________________________ 118 Internal format __________________________________________________________________ 119 Caching ________________________________________________________________________ 119 User settings ____________________________________________________________________ 119 Current time ____________________________________________________________________ 119 Getting date ____________________________________________________________________ 119 Printing date ____________________________________________________________________ 120 Timezones ______________________________________________________________________ 120 Date & time separation ___________________________________________________________ 120 Calculations ____________________________________________________________________ 120 Conversion