2. Intro
• Power Hour
– Developer / Admin Resource
– Promote Successful Implementations
• Ticomix
– SugarCRM “Advanced” Partner
– 2014 Rising Star
– Consulting, Development & Support
– www.ticomixcrm.com
– @TicomixCRM / @TicomixInc
• Webinar Logistics
3. About Jeff Bickart
• Sugar Developer since version 4.0a
• Director of Engineering of a Voice-Enabled CRM
startup
• Chief Technology Officer, NEPO Systems − SugarCRM
GOLD Partner
• CRM Evangelist, Ticomix
• Contact Information
– @bickart
– www.linkedin.com/in/bickart
4. Sugar Development 101
Sugar as a Platform
• MVC (Module View Controller)
– Server Side
– Client Side
• ORM (Object Relationship Mapping)
– Beans
– Relationships
• API (Application Programming Interfaces)
– REST
– SOAP
• How and where to add customizations
– Extension Framework
– Logic Hooks
• Debugging tips and techniques
– IDE – Xdebug
– Logging
5. Development 101
• Directories of Interest
– custom
– cache
– data
– Modules
– include
– vendor
– sidecar
• Where do my changes belong?
– custom
– custom
– custom
– modules
6. Model, View and Controller (MVC)
SuiteCRM, Sugar 6, Sugar 7 #bwc
• Model
– SugarBeans
• View (Sugar 6 and Sugar 7 #bwc)
– Displaying information to the browser
• Detail View
• Edit View
• List View
– Two parts to a view
• metadata
– Example: custom/modules/Accounts/metadata/editviewdefs.php
• class loader
– Example: custom/modules/Accounts/views/view.edit.php
• Controller
– actions such as
• Display
• Save
• Etc.
7. Model, View and Controller (MVC)
Sugar 7 (client)
• Model
– Backbone.js
• gives structure to web applications by providing models with key-value binding and custom events,
collections with a rich API of enumerable functions, views with declarative event handling, and
connects it all to your existing API over a RESTful JSON interface.
• View
– Layouts
• Layouts are components which render the overall page. They are used to define the rows, columns,
and fluid layouts that the content is displayed to the user in.
– Views
• Views are components which render data from a context and may or may not include field
components. Example views include not only record and list views but also widgets
• Utilizes HandleBars and Controllers
– Fields
• Fields render widgets for individual values pulled from the models and handle formatting (or
stripping the formatting of) field values. Just like Layouts and Views, Fields also extend Backbone
Views
• Utilizes HandleBars and Controllers
8. Object Relationship Mapping (ORM)
• Beans
– CRUD (Create, Read, Update, Delete)
– Defined via Variable Definitions (i.e., vardefs) and
Templates
• Relationships
– Are the basis for linking information within the system
9. Sugar Object Templates
• Basic
– The building blocks needed to communicate with the DB.
– Fields
• id, name, date_entered, date_modified, created_by, modified_user_id, created_by, description, deleted
– Associated Relationships
• Company
– Additional information that pertains to a company; addresses, industry, revenue, etc.
• File
– Addition logic in order to be able to upload and maintain files in a module
• Issue
– This is the basis of cases
• Person
– Additional information as it pertains to a person; first_name, last_name, email addresses, etc.
• Sale
– The building blocks of an Opportunity; amount fields
10. Object Relational Model
• 99.9% of the time you do NOT need to write SQL!
• If you think that you need SQL you are doing something
WRONG!
• Sugar is Object Oriented
• SugarBean
– Performs all operations with the DB
• Create, Retrieve, Update, Delete
– All Modules extend the SugarBean
– Examples
• Leads -> Person -> Basic -> SugarBean
• Accounts -> Company -> Basic -> SugarBean
• Opportunity -> Sale -> Basic -> SugarBean
11. SugarBeans
data/SugarBean.php
• SugarBean is a component, that represents persistent
data maintained in a database
• Types
– basic, company, file, issue, person, sale
• Examples
– Accounts, Documents, Cases, Contacts, Opportunities
• Basic SugarBean
– All Beans extend basic which provides the fields:
– id, name, date_entered, date_modified, modified_user_id,
created_by, description, deleted
12. Vardefs (variable definitions)
• Sugar uses a file based approach to store all of the
information to describe each field as it relates to a module
and how that information should be stored in the DB
• Every module that communicates to the DB will need a
vardefs.php file
– <module>/vardefs.php
– At the end of the file, you must tell Sugar which template to base
your module upon
• if (!class_exists('VardefManager')) {
require_once 'include/SugarObjects/VardefManager.php';
}
VardefManager::createVardef('TCX_Passwords', 'TCX_Passwords',
array('basic', 'team_security', 'assignable'));
13. Vardefs
Continued
• Quick Repair and Rebuild
– Builds the aggregated version of the Vardefs into
cache/modules/<mymodule>/<MyModule>Vardefs.php
• Sugar uses this file for
– communicating to the DB
– display subpanels
– Join field
– Adding fields to the DB
– Aggregated Version comes From
• modules/<mymodule>/vardefs.php
• Template
– Include/SugarObjects/templates/
• fields_meta_data (fields added via Studio)
• custom/Extension/modules/<mymodule>/Ext/Vardefs
– sugarfield_field_name.php – generated when using Studio
14. SugarBean
Tips & Tricks
• Obtain a Bean by ID
• $account = BeanFactory::getBean(‘Accounts’, $id);
• $account = BeanFactory::getBean(‘Accounts’, $id,
array(‘disable_row_level_security’ => true));
• Obtain a set of Beans with filter
– Sugar 6
• $account = BeanFactory::newBean(‘Accounts’);
• $results = $accounts->get_list("", "accounts.assigned_user_id = '1'", 0);
– Sugar 7
• $accounts = BeanFactory::newBean('Accounts');
• $query = new SugarQuery();
• $query->from($accounts)->where()->equals('assigned_user_id','1');
• $results = $accounts->fetchFromQuery($query);
18. Sugar 6 Root Directory Structure
• data - This directory contains files related to SugarCRM's Model. You will find information about SugarBean as well as how relationship
are connected to the SugarBean
• examples - In this directory you will find a variety of examples on how to connect external sources into SugarCRM. There is a SOAP
example and some example configurations about
• include -- SugarCRM's framework and 3rd party libraries, except Zend and Xtemplate, used by SugarCRM
• install -- Logic to install SugarCRM. Once installed the files in this directory are unused
• jssource -- Original JavaScript files before they have been minified.
• log4php -- Deprecated logger replaced with include/SugarLogger: SugarCRM no longer uses log4php but the directory remains
• metadata -- This directly contains "join table" definitions. For example the definition of the accounts_contacts table
• ModuleInstall --Utilized by Upgrade Wizard, Module Loader and silentUpgrade to update the SugarCRM environment
• modules -- SugarCRM MVC for each section of the application. Examples include accounts and contacts
• portal -- Customer Portal: This code only works for Sugar Enterprise and Sugar Ultimate
• service -- WebServices are supported from here both REST and SOAP
• soap -- Deprecated version of the SOAP WebService, see the service directory for updated versions
• themes -- User Interface definitions that Sugar supports are located in this directory
• upload -- new location in 6.4. This is where uploaded files will be stored. Prior to 6.4 this directory was under cache
• xtemplate -- A library by PHP Xtemplate that is provided for backward compatibility. SugarCRM now uses the smarty Template Engine.
smarty can be found at include/smarty
• zend -- Portions of the Zend Framework that are used by SugarCRM
• cache -- This directory is used by SugarCRM application to store converted metadata that can be displayed by the SugarCRM application.
Items include screens, and data
• custom --All upgrade safe customization will go into this set of directories. Anything that is in here is safe from SugarCRM upgrade wizard
19. Sugar 7 Directory Structure
• Ext
– The Extension Framework can now be used from the core of Sugar
including within the core modules. So it is now possible to create
system wide extensions in custom/Ext
• ModuleInstall
• api
• cache
• clients
– Sugar UX code;
– Sugar now supports multiple clients
• base – Standard UX
• portal – Portal UX
– UX Elements such as SugarFields, Layouts, View, Dashlets
• custom
• data
• examples
• include
• install
• jssource
– JavaScript source code
• metadata
• mobile
– Access to mobile view of the product for example:
https://crm.ticomix.com/mobile
• modules
• portal2
– Enterprise portal
• service
• sidecar
– files used by the new UX, sidecar. Document can be found here:
https://jsduck.test.ticomix.net/
• soap
• styleguide
– Files used by the sytleguide available in Sugar
https://crm.ticomix.com/#Styleguide
• themes
• upgrade
• upload
• vendor
– All code not created by sugar has been moved to the vendor directory
which is consistent with composer
20. Logic Hooks
• Similar in nature to Workflows
• Not limited in functionality
• Examples:
– Communicate with 3rd Party Web Services
– Update data by assignment
– Send Notification(s)
• Location
– Sugar’s documentation doesn’t specify where Logic Hooks should reside.
– Module Logic Hooks
• custom/modules/<module>/LogicHooks - keeps them all together
• Prefer if you have a separate file for each Logic Hook; Easier to update a single file without effecting other Logic
Hooks
– custom/modules/<module>logic_hooks.php
<?php
/ $hook_version = 1;
$hook_array = Array();
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(10, 'Assign Authorize.Net to the
Contact',
'custom/modules/Leads/LogicHooks/UpdateAuthorizeNet.php','UpdateAuthorize
Net', 'addContactToAuthorizeNet');
28. Future Webinars
Topics Subject to Change
• Future Topics
– Using the SugarJobQueue
– LogicHooks
– Deploying Packages
– Layouts
– Views
– Fields
– Building a Wizard
Notas del editor
Why – we are experts in the field of SugarCRM and have been doing this for a long time and we recognize that its sometimes challenging to the the support you need, specifically for developers. Given our investment in the Sugar community we think its important to make sure that ALL users of sugar are finding success, deploying solutions that provide true value for your business…
That said, we know we have a user group here that have varying technical backgrounds, some of you are admins and some are developers. When initially conceived, this Power Hour was designed with the Developer in mind, but due to the response we’ve received from this, we are considering creating two separate tracks, one for developers and one for admins. Regardless of your position, I would encourage you to stay connected today to get a sense of how these webinars will be conducted moving forward… So, what I’d like to do real quick, is have everyone simply answer this one poll question so we can get a better sense of our demographic.
Ticomix was founded in 2000 and has locations and people across the country. We are currently an “Advanced” SugarCRM partner, making us one of the top 20 partners in the North America and we have a relationship with Sugar dating back to 2009. Last year we received the sole “Rising Star” award from Sugar, which demonstrates their confidence in Ticomix to continue to develop as one of the top Sugar providers in the world… We provide a full suite of services ranging from Sugar consulting through to on-going support.
So, I know that was brief, but we want to turn this over to Jeff as quickly as possible to try and give you as much value from this hour as possible.. So just a couple of logistics.