There is a pretty common issue that we have seen come up again recently a few times. How to best support features of different editions of SugarCRM without knowing the ultimate edition that a module gets installed on. More specifically, how to support team security while also allowing a module to support CE. It comes up in two different scenarios:
- Scenario 1: A module created originally for Pro or above wants to add support for CE
- Scenario 2: A module created originally for CE wants to add support for Pro and above
In Scenario 2, not adding support for teams won't cause any blocker issues that prevent SugarCRM from being usable. The main issue there is that an organization just can't take advantage of team security for that module. Obviously adding support for teams can be a big benefit and need for many organizations.
Scenario 1 is where you can run into big issues. If your module was originally intended for Pro or above and now supports CE and proper care isn't taken your users may/will run into issues that render the module useless. Here is a common error message that will appear:
Msg 207, Level 16, State 1, Line 9 Invalid column name 'team_set_id'.
The change required to cover both Scenario 1 and 2 is straight forward. We check the flavor (edition) of the current instance in the vardefs and turn on/off team support based on what we find:
<?php | |
$dictionary['my_Module'] = array( | |
'table'=>'my_module', | |
'audited'=>false, | |
'fields'=>array ( | |
//....removed for gist | |
), | |
); | |
//check to see which edition we are installed on and enable/disable team_security as appropriate | |
global $sugar_flavor; | |
if(!empty($sugar_flavor) && $sugar_flavor=='CE'){ | |
VardefManager::createVardef('my_Module','my_Module', array('basic','assignable')); | |
} else { | |
VardefManager::createVardef('my_Module','my_Module', array('basic','team_security','assignable')); | |
} |
By checking the $sugar_flavor we can determine whether we want to enable team security or not. It's as simple as adding this to any module's vardefs.php that needs to support teams.
-
Provident ® InterAction
FEATUREDThe InterAction add-on for Sugar Sell, Sugar Serve and Enterprise enables you to stay on top of your last communication with leads, contacts and accounts. This powerful tool allows you to see the date... -
Filter Deployer
Allow users to quickly and easily share filters to other users. Admin users can create templates of filters from multiple users to deploy to users, teams, or roles. -
Epicor Kinetic Integration - SYNC by Commercient
FEATUREDYour ERP Accounting data is integrated with your SugarCRM when you use Commercient’s SYNC app. SYNC Accounts, Contacts, Invoices, Sales Orders, Products, Pricing, Inventory, and more! - Show more addons