id
stringlengths
14
16
text
stringlengths
33
5.27k
source
stringlengths
105
270
7a1f35b2e450-1
Sugar Products Sugar has several CRM products available: Sugar Sell, Sugar Serve, and Sugar Enterprise, which are all sold under a commercial subscription agreement. These products are developed by the same development team using the same source tree with different modules and features available depending on the product. A comparison of each product's features is available in the License Types section of the User Management documentation in the Administration Guide. Basic Development Rules for Sugar Products Unless SugarCRM has given you express permission to do so, the following are what not to do when you are configuring, customizing or modifying this Sugar product: Do not remove or alter any SugarCRM or Sugar copyright, trademark or proprietary notices that appear in the Sugar products. Do not "fork" the Sugar software (e.g., take a copy of source code from this product and start independent development on it, creating a distinct and separate piece of software). Do not modify, remove or disable any portion of SugarCRM's "Critical Control Software." Do not combine or use the Sugar products with any code that is licensed under a prohibited license (e.g., AGPL, GPL v3, Creative Commons or another similar license that would "taint" the Sugar products and require you to share the source code for this product with a third party). Do not use any part of the Sugar products for the purpose of building a competitive product or service or copying its features or user interface. Development Tools Sugar has a set of built-in tools that you can use to your advantage when troubleshooting or developing. Developer Mode Developer Mode will allow for Sugar to recompile cached files when the page is reloaded. The following file types are rebuilt: Handlebar Templates (.hbt) Smarty Templates (.tpl) JavaScript Controllers (.js)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/index.html
7a1f35b2e450-2
Smarty Templates (.tpl) JavaScript Controllers (.js) When Developer Mode is enabled, The Sidecar JavaScript library references the full JavaScript files located in ./sidecar/ rather than the concatenated and minified cached versions. You can turn on Developer Mode by navigating to Admin > System Settings. For more information, please refer to the System documentation. Note: This setting should remain off unless developing because it will degrade system performance. Diagnostic Tool When troubleshooting issues, you may find the diagnostic tool to be helpful. This tool will export a zipped package containing the requested diagnostics and is available even if you are hosting your instance on Sugar's cloud service. The diagnostic tool has the ability to export the following: SugarCRM config.php SugarCRM Custom directory phpinfo() MySQL - Configuration Table Dumps MySQL - All Tables Schema MySQL - General Information MD5 info Copy files.md5 Copy MD5 Calculated array BeanList/BeanFiles files exist SugarCRM Log File Sugar schema output (VARDEFS) You can use the diagnostic tool by navigating to Admin > Diagnostic Tool. For more information, please refer to the System documentation in the Administration Guide. Composer When building applications, some developers prefer to use Composer to manage their external dependencies and make them more intuitive. For more information, please refer to the Composer documentation.   TopicsDevelopment MethodologyAn overview of code development methodologies for Sugar platform customizationsComposerUsing Composer as a dependency management system for third party libraries.Delivery and Deployment Guide for EnterprisesGuide to customization deployment steps used by Sugar Professional Services when engaged in CRM projects.Sugar 12.3 to 13.0 Migration GuideThe purpose of this document is to provide insight to Sugar Developers for upgrading custom Sugar code, extensions, and integrations to the Sugar 13.0 (Q2 2023) release.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/index.html
7a1f35b2e450-3
Last modified: 2023-05-23 16:27:13
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/index.html
606cd4176aa6-0
Composer Overview Composer dependency management is the de facto standard for managing PHP dependencies. Sugar platform ships with all required code bundled and optimied together for our developers. The installer will, however, deploy both composer.json and composer.lock in the web root directory as a reference of all dependencies which are controlled by Composer. Autoloader Sugar has a custom autoloader that is PSR-0 and PSR-4 compliant and integrates with Composer's mapping definitions. Integrations When updating the Composer configuration, Composer will generate different mappings based on the settings of every dependency: Class map PSR-0 map PSR-4 map Include paths (deprecated) SugarCRM's autoloader uses those generated maps directly to initialize itself and to figure out how to load different classes. Internals To prevent endless file stats, Sugar's autoloader maintains a full list of all files at its disposal. This list is only generated once and is maintained in ./cache/file_map.php. Most of the Sugar codebase uses the autoloader to determine whether a file is available rather than performing expensive file_exists calls. A second file, stored in ./cache/class_map.php , maintains a flat list of class-name-to-file mappings. When you make any changes to the file system, clear both files before testing new code. Optimization When updating dependencies through Composer, Sugar team uses the optimize flag: composer update --optimize-autoloader --no-dev".  By doing so, Composer will scan all files in the packages it manages and create a full list of PSR-0 and PSR-4 class name to file mappings, instead of performing this lookup on the fly by the autoloader itself on runtime. Frequently Asked Questions Is the composer package required to install a Sugar instance?
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Composer/index.html
606cd4176aa6-1
Frequently Asked Questions Is the composer package required to install a Sugar instance? No. The Sugar installer ships with all required code bundled together. The installer process does not execute any Composer commands. The installer will deploy both composer.json and composer.lock in the web root directory as a reference of all dependencies which are controlled by Composer. Why does Sugar ship ./composer.json and ./composer.lock if the installer doesn't rely on them? Composer is used internally during development to manage Sugar's dependencies on third-party libraries and packages. The Composer files are shipped during development to manage Sugar's dependencies on third-party libraries and packages. The composer files are shipped with the product to give our customers the ability to expand from them. Is the Composer package required to upgrade a Sugar instance? No. The Sugar upgrader ships, just like the installer, with all required code bundled together. The upgrade process will validate the present Composer configuration and verify if it is compatible with the upgrade. In the case of a custom configuration, the upgrade process will report any issues which need to be resolved by the system administrator before the upgrade can proceed. Why are there no wildcards in the version constraints? Doesn't composer.lock keep track of exact version numbers? The lock file is designed to lock the dependencies to a specific version, but to protect our customers from unintentionally pulling in newer versions of dependencies owned by SugarCRM, we have chosen to use explicit version numbers in the composer.json file too. May I change the version number of a package? You cannot change version numbers for packages added by Sugar. Sugar will always configure exact version numbers for all of its dependencies. Changing these version numbers will result in an unsupported platform. The version constraints of packages not owned by Sugar may be modified at the developer's discretion. Can I use Composer's autoloader?
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Composer/index.html
606cd4176aa6-2
Can I use Composer's autoloader? We strongly recommend against using Composer's autoloader. The Sugar autoloader is fully compatible with the PSR-0 and PSR-4 autoloading recommendations from PHP-FIG, which makes the registration of an additional autoloader like the one from Composer redundant. Sugar's autoloader consumes the different mappings which are generated by Composer directly. How can I optimize the autoloader? Sugar ships with an optimized class map out of the box, which is pre-generated through Composer. This class map contains all different class to file mappings known to the dependencies managed by Composer. When customizing the Composer configuration, it is sufficient to run composer update --optimize-autoloader which will refresh the class map. SugarCRM's autoloader takes full advantage of this optimization. Can I load customizations in Sugar through Composer? Although not yet available out of the box, we are investigating this as a future capability. Can I move the vendor directory out of the web root? You cannot currently move the vendor directory, but we are investigating this as a future capability. The Composer integration in Sugar is not flexible enough for me. What can I do? We continuously strive to make our platform better and to facilitate both end users and developers. Our goal is to deliver a state-of-the-art environment. Do not hesitate to reach out to Sugar Support if we have overlooked your use case or if there too many constraints in the current implementation to make this a useful feature. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Composer/index.html
6c6a0dcec1d5-0
Delivery and Deployment Guide for Enterprises Overview SugarCRM Professional Services has a set of best practices for managing instances, delivering upgraded customizations, and deploying those upgraded customizations into Sugar on-site for our Enterprise customers. The following is an example of deployment practices used by SugarCRM Professional Services team when engaged on Enterprise Sugar development projects. It does not list all possible customizations that can be made in the system, it is intended to be used as a guide for how to automate the deployment of certain types of customizations into an on-premise Sugar instance. The techniques below cannot be used with Sugar's cloud service. Deploying Application Configuration and Metadata Use Case: Deployment of System Settings System settings are stored in various places. In this section, we will address each type of storage for settings, and how to migrate each. Storage types: config_override.php This is a file stored in the Sugar root directory that allows for overriding core config values (found in config.php). In the UI, the main place to make changes to this is via Admin -> System Settings database 'config' table It is loaded, used, and accessible throughout the Sugar application through the Config API. System Tab Settings Forecasting Settings Portal Settings This is a simple key/value/category store. There aren't too many components that use this. Here are some:   config_override.php System considerations: File System: config_override.php is placed in Sugar web root directory  Scripts required PHP You will need to write a script to read the current config_override.php and merge the existing array with the new values you'd like to change. This can be done one time, and re-used for all future config_override.php changes   Steps to migrate: Assess the values to be changed, added, or removed
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
6c6a0dcec1d5-1
Steps to migrate: Assess the values to be changed, added, or removed Write a script to read the existing config_override.php, make the changes to the array, and re-write the file back to the system.   database 'config' table System considerations: Database: The 'config' table stores all these values. They are stored in a very simple table schema. Scripts required PHP Write a simple PHP script to use Sugar object API. See Figure 1   Steps to migrate: Write script to use our object API for config table changes (See Figure 1) Copy script to Sugar root directory Execute the script Remove the script  Screenshots: Figure 1:     Use Case: Deployment of Reports The customer creates a report in the Reports module. They would like to deploy that report so that end users can all access and run it. System considerations: Database Row is inserted into the Reports module (saved_reports table) (For new team combinations) Row is inserted into the team_sets table (For new team combinations) Rows are inserted into the team_sets_teams table Scripts required SQL Retrieve the relevant rows (saved_reports, team_sets, team_sets_teams) and create a SQL script to insert them. Additional notes: In the System considerations section, "new combination of teams" means that when creating the report, the end user created the Report with a set of teams that doesn't exist on any other record. This results in new entries in the team_sets and team_sets_teams tables. Steps to migrate: Build a report in the dev instance Select the database rows associated with that report (saved_reports, possibly team_sets and team_sets_teams tables) example: "SELECT * FROM saved_reports WHERE id = 'REPORT_ID'"
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
6c6a0dcec1d5-2
example: "SELECT * FROM saved_reports WHERE id = 'REPORT_ID'" Export the row/rows into a SQL file Execute on the next system   Use Case: Deployment of Dashboards The customer wants to deploy the pre-built dashboards in an automated way. See Figure 1 below. This example has two dashboards, "Help Dashboard" and "My Dashboard". Each dashboard has zero or more dashlets. System considerations: Database: Row is inserted into the dashboards table for each user dashboard. The metadata column stores all the dashlets associated with that dashboard, and the assigned_user_id column stores the user who will see this dashboard. Scripts required PHP After deploying the dashboards you will need to run the Quick Repair and Rebuild script found in the admin section. Custom scripts: YES (if applying to multiple users) Because users and id are dynamic, if applying to multiple users, you will need a custom script to retrieve those user ids and set them for each sql insert. SQL Script required to import the entry from the dashboards table. Steps to migrate: Build a dashlet against a specific user Select the database rows associated with that user example: "SELECT * FROM dashlets WHERE assigned_user_id = 'USER_ID'" Pick the dashboard you'd like to apply to other users, and export it into a SQL file Decide what set of users you need to create the dashboard for. Write a script to pull that list of users, dynamically set the assigned_user_id and id (id must be unique) with the insert query you exported in step 3, and run for each one of those users.   Screenshots: Figure 1   Use Case: Deployment of Roles The customer wants to deploy the roles in an automated way. This includes creating new roles and updating previously existing roles. System considerations:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
6c6a0dcec1d5-3
System considerations: Database: Row is inserted into the acl_roles table for each role setting. Depending on how specific the role is, we might have acl_fields and acl_actions mapped to roles through acl_roles_actions Scripts required PHP Sugar has a SugarACL object API that can be used to create, read, and write roles and role definitions.  Steps to migrate: Write a script using our object API to create or write roles Define the metadata for the changes or additions to be made Write logic to add/update based on metadata Execute script on dev instance and confirm changes Use script to promote to next instance Note: See functional sample script below https://gist.github.com/sadekbaroudi/3191513e2bbce2170326   Use Case: Deployment of Teams The customer wants to deploy the teams in an automated way. This should be done via the Sugar object API. System considerations: Scripts required PHP Follow steps in "Additional Notes" section below for details on building Team scripts. TeamSets are cached per user by SugarCache.  SugarCache should be cleared after installing new teams. Additional notes: To build a script to do this, see the following: modules/Teams/Save.php This file is called when a user posts data through the form in the UI. This code should be replicated (until the Teams module is refactored). modules/Teams/Team.php function save() - this should be called as part of the save function mark_deleted() - this should be called on the object when you want to delete a team, be sure to make sure there are no related users before doing so. Steps to migrate: Write a script using our Teams object API Create needed team object Set appropriate data on object and/or POST data After saving, potentially add users to the team
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
6c6a0dcec1d5-4
Set appropriate data on object and/or POST data After saving, potentially add users to the team Execute script on dev instance and confirm changes Use script to promote to next instance   Use Case: Deployment of User Settings The customer wants to deploy the user settings in an automated way. There are a couple of places where we store User settings. Storage types: User Preferences This is a key value pair with a serialized and then base64 encoded value. We store many user preferences, all encoded. These are non-critical settings, and can be blown away. However, doing so will require the user to reconfigure their preferences. The data is stored in the user_preferences table. This includes data such as:  Subpanel display order, Timezone preferences, etc. Users module settings  These are direct values on the Users module (users table). Here we track persistent User attributes such as: Address, Phone number, etc  User preferences System considerations: Database: Row is inserted into the user_preferences table for each user setting change. Scripts required PHP  In order to update values with a user's preferences, you would need to write a custom script to read, update, and rewrite to the user_preferences table  Steps to Migrate: Write a script using our User Preferences API Query the database to retrieve the row for a given user base64 decode the value unserialize the value update the data required serialize the data base64 encode rewrite the row to the database (repeat for all applicable users) (See modules/UserPreferences/UserPreference.php or modules/Users/User.php, specifically getPreference() and setPreference()) Load the User object Call getPreference for the specified value Make changes Call setPreference for the specified value Better performance method (direct database queries and updates):
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
6c6a0dcec1d5-5
Call setPreference for the specified value Better performance method (direct database queries and updates): More robust, but slower performance method (API):   User table   System considerations: Database: Users table is updated Scripts required: SQL You can directly update the Users table directly, provided the data is not encoded or encrypted (like password).   Steps to Migrate: Write a SQL script to update values in the users table based on need Execute script on dev instance and confirm changes Use script to promote to next instance   Use Case: Deployment of custom fields A user wants to deploy custom fields created in an automated way. This includes anything created through Studio. System considerations: File System: Files are potentially created in the following directories: Custom field vardef:custom/Extension/modules/<module_name>/Ext/Vardefs/sugarfield_<field_name>.php Custom field label (and app_list_string if necessary): ./custom/Extension/modules/Accounts/Ext/Language/en_us.lang.php Database: The <module_name>_cstm table is created, if it doesn't already exist. The field <field_name>_c is created against that table Scripts required A Quick Repair and Rebuild is required after copying the files and fields_meta_data table values. SQL You will need to insert the relevant entries from the fields_meta_data table Steps to migrate: Export the fields_meta_data entries for the custom fields into a script Copy the files for the custom fields Apply #1 and #2 to another system, and execute a Quick Repair and Rebuild Execute the DDL generated by the QRR above   Use Case: Deployment of custom modules
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
6c6a0dcec1d5-6
  Use Case: Deployment of custom modules A developer creates a custom module and wants to deploy it, this use case refers to a basic module, because each additional feature (logic hooks, relationships,dependencies, etc) has its  own deployment scenario. System considerations: File System: ./custom/Extension/application/Ext/Include/<package_name>.php ./modules/<new_module>/* ./custom/modules/<new_module>/* ./custom/themes/default/images/*<new_module>*.(gif/png) ./custom/Extension/modules/<new_module>/* Database: new tables <new_module> and <new_module>_audit Note: the DDL gets generated by the Quick Repair and Rebuild script, at which point you can execute manually or automatically fields_meta_data table Note: this stores all the custom fields built through Studio (not Module Builder) after the module is deployed. Make sure you retrieve all rows from this table that apply to this module and create a SQL script to insert into the next system Scripts required After deploying the custom module, you will need to run the Quick Repair and Rebuild script found in the admin section. SQL Script required to import the entry from the <new_module> and <new_module>_audit table. Script required to import fields_meta_data table entries for this module (if there are any) Additional notes: For a full custom module deployment scenario, this deployment scenario should be ran first then all of the extended module features deployment scenarios should be run: Steps to migrate: Copy all files listed in file system section above Export fields_meta_data table entries as apply to the custom module (if any) Run Quick Repair and Rebuild Either manually or automatically run the DDL output from QRR Test functionality  Use Case: Deployment of custom Relationships
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
6c6a0dcec1d5-7
Test functionality  Use Case: Deployment of custom Relationships A user wants to deploy custom relationships created in an automated way. This includes anything created through Studio.  Follow the same instructions as for Custom Fields, but: Ignore the fields_meta_data table Be sure to consider the following: custom/Extension/modules/<side_1_of_relationship>/Ext/ custom/Extension/modules/<side_2_of_relationship>/Ext/ custom/Extension/modules/relationships/ Otherwise, the same process applies. Use Case: Deployment of custom View or Layout metadata (Web) The user creates custom layouts and views for web from studio and wants to deploy them. System considerations: File System: Layouts: ./custom/modules/<module>/clients/<platform>/layouts/<layout>/ <layout>.php Views Creating a layout from Studio actually augments the Sidecar view metadata instead of Sidecar layout metadata ./custom/modules/<module>/clients/<platform>/views/<layout>/ <layout>.php Scripts required After deploying you will need to run the Quick Repair and Rebuild script found in the admin section.  Additional notes: For layouts(record) you have the option to simply save the modified layout. In this case the metadata for the layout can be found in ./custom/working/modules/<module>/<platform>/views/<view>/<view>.php Layouts created from studio create views in .custom/modules/<module>/viewsThe created views can be record | list | selection-list For the two popup layouts(created from studio), extra metadata is provided in the ./custom/modules/<module>/metadata/popupdefs.php   Use Case: Deployment of custom View or Layout metadata (mobile) The user creates custom layouts and views for mobile from studio and wants to deploy them. System considerations: File System: YES Layouts:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
6c6a0dcec1d5-8
System considerations: File System: YES Layouts: ./custom/modules/<module>/clients/mobile/layouts/<layout>/ <layout>.php Views ./custom/modules/<module>/clients/mobile/views/<view>/ <view>.php Database: NO Scripts required After deploying you will need to run the Quick Repair and Rebuild script found in the admin section. Additional notes: Layouts and views are handled the same as with web. From Studio, you can augment detail, edit and list views. Deploying Application Code and Integrations Use Case: Deployment of custom CSS (LESS)   In order to update branding, developers can deploy customized CSS. System considerations: File System: YES  ./custom/themes/custom.less Scripts required You will need to run the Quick Repair and Rebuild script found in the admin section to rebuild the Sugar CSS bundles. Use Case: Deployment of Logic Hooks and Web Logic Hooks The developer creates custom logic hooks, they want to deploy them. System considerations: Logic Hook: File System: YES  application hooks : ./custom/Extension/application/Ext/LogicHooks/<file>.php module specific hooks: ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php Scripts required You will need to run the Quick Repair and Rebuild script found in the admin section to rebuild the extensions. Web Logic Hook: Database: YES Only for weblogic hooks : row is inserted into the weblogichooks table.  Scripts required After deploying the custom hooks and database entry in the weblogichooks table, you will need to run the Quick Repair and Rebuild script found in the admin section. SQL Script required to import the entry from the weblogichooks table. Use Case: Deployment of custom API endpoints
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
6c6a0dcec1d5-9
Use Case: Deployment of custom API endpoints The user creates a custom api endpoints, he wants to deploy them.  System considerations: File System clients/<platform>/api/* modules/:module/clients/<platform>/api/* custom/clients/<platform>/api* custom/modules/<module>/clients/<platform>/api/* Scripts required After deploying the custom api you will need to run the Quick Repair and Rebuild script found in the admin section. This will rebuild the ./cache/file_map.php and ./cache/include/api/ServiceDictionary.rest.php files to make your endpoint available. Additional notes: Logic for how api endpoints are loaded, can be found in ./include/api/ServiceDictionary.php (where api endpoints are loaded from, how they are built on Quick Build and Repair, etc.) Use Case: Deployment of custom Administration Panels The user creates custom administration panels, and wants to deploy them. System considerations: File System: ./custom/Extension/modules/Administration/Ext/Administration/<file>.php ./custom/Extension/modules/Administration/Ext/Language/<langtype.name>.php ./custom/themes/default/images/<icon_image_name>.<img_extension> and depending on the admin panel url, either : ./custom/modules/<linkUrlModule>/* or ./custom/modules/<linkUrlModule>/clients/base/layouts/<route_name>/* ./custom/modules/<linkUrlModule>/clients/base/views/<route_name>/* Scripts required After deploying the admin panels, you will need to run the Quick Repair and Rebuild script found in the admin section. Additional notes: The admin url can specify new sidecar routes, old bwc routes, edit view files, plain scripts, or just open a drawer. Determining the additional resources to be copied may be impossible without a standard in place.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
6c6a0dcec1d5-10
Use Case: Deployment of custom Jobs / Schedulers The user creates custom jobs and schedulers, and wants to deploy them. System considerations: File System: YES: ./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/<jobname>.php ./custom/Extension/modules/Schedulers/Ext/Language/<langtype.jobname>.php Database: YES Row is inserted into the schedulers table, if a job is added as a scheduled job using Administration > Scheduler. Scripts required After deploying the custom jobs, you will need to run the Quick Repair and Rebuild script found in the admin section. SQL Script required to import the entry from the schedulers table. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Delivery_and_Deployment_Guide_for_Enterprises/index.html
efa75352ce88-0
Sugar 12.3 to 13.0 Migration Guide Overview The purpose of this document is to provide insight to Sugar Developers for upgrading custom Sugar code, extensions, and integrations to the Sugar 13.0 (Q2 2023) release.  Cloud and On-Site Sugar Release For those looking to upgrade from Sugar 12.0, you will be catching up with additional content released in the 12.1 (Q3 2022), 12.2 (Q4 2022), and 12.3 (Q1 2023) cloud-only Sugar releases. In addition to this guide, please review the Sugar 12.1, Sugar 12.2, and Sugar 12.3 migration guides and the release notes linked below to get a full view of changes since Sugar 12.0. REST API Version Number The current version for the Sugar REST API is 11_20.  Changes That May Affect Developers The changes in Sugar 13.0 (Q2 2023) that could cause an immediate impact on customizations and integrations that were built for earlier versions of Sugar are highlighted in the following Developer Blog post in the SugarClub community:  Sugar 13.0 (Q2 2023) Customization Guide Related Documents For more information about what changed in Sugar 13.0.x, please refer to the following related documents: What to Expect When Upgrading to Sugar 13.0 (Q2 2023) 13.0.0 Upgrade Paths 13.0 Installation and Upgrade Guide 13.0.x Supported Platforms Release Notes Sugar Sell 13.0.0 Release Notes Sugar Serve 13.0.0 Release Notes Sugar Enterprise 13.0.0 Release Notes
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Migration_Guide/index.html
efa75352ce88-1
Sugar Enterprise 13.0.0 Release Notes Last modified: 2023-04-05 00:05:28
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Migration_Guide/index.html
32805dcbf4a7-0
Development Methodology Overview This page discusses standard practices that we recommend for improving the success rates of Sugar development projects.  Development Best Practices When developing Sugar® customizations as part of an on-site CRM project implementation, we recommended placing the entire Sugar application filesystem under source code management. Sugar developers know that customizations made to Sugar are placed under the ./custom/ directory. But during the lifecycle of a CRM implementation, you will need to upgrade Sugar versions, which will change core files. Many projects will also need to track other related project files that may not all be Sugar platform code. For example, pre-flight SQL scripts, data migration scripts, Web server configuration settings, etc. For SugarCloud projects and ISVs, if you are building a custom module package or integration designed to be installed into many Sugar instances (including SugarCloud instances), then tracking only ./custom/ directory files should be enough. Using .gitignore Files Today, many developers choose to use Git as their source control management. There are certain Sugar application files that you do not want to track; most of these are generated files that are created at runtime or are Sugar instance-specific configuration files. Below is a sample .gitignore file that you can use or adapt to the source control management system of your choice. *.log /.htaccess /config.php /config_override.php /cache /upgrades/module /upload /custom/blowfish /custom/history /custom/application/Ext /custom/modules/*/Ext /custom/Extension/**/*orderMapping.php Recommendations for Development Teams Code quality is important to maintain because Sugar customizations run in the same environment as the rest of the Sugar application. Here are a few best practices to help development teams uphold code quality. Adopt an appropriate Git workflow for development. For reference, see Atlassian's tutorial on Git workflow options.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Development_Methodology/index.html
32805dcbf4a7-1
Develop within feature branches that are tested before being merged back into master to keep master stable. Avoid workflows that involve developers committing directly into the master branch to prevent code destabilization. Development teams should always perform code reviews before merging in new code. Deploying Sugar Code Where you plan to deploy Sugar code is the biggest factor in determining how Sugar code should be deployed and how your project should be managed. Are you working on a Sugar project for an on-premise Sugar implementation? Are you working on a custom module that you plan on distributing through SugarExchange? Are you planning a solely REST API integration? The answers to these questions guide how you should develop and deploy Sugar code. Sugar on-site projects : Develop these customizations using the exact version and flavor of Sugar that you plan to use in production. SugarCloud projects : Develop these customizations on the latest available version of Sugar for the particular flavor the customer has purchased. Custom modules or integrations : If you plan on distributing your customization to many Sugar customers via SugarExchange or channel partners, design your customization with Sugar's cloud service in mind. Sugar's cloud service is more restrictive than our on-site installs regarding supported customizations. A customization designed for Sugar's cloud service can be supported in Sugar on-site instances, but the inverse is not always true. For more information on Sugar's cloud service restrictions, please refer to the SugarCloud Policy Guide. Packaging The packaging of customizations is not a concern for many Sugar projects. Many projects just use Git (or some other file version control) to manage the distribution and deployment of Sugar code customizations. However, there are situations where the packaging of Sugar customizations is necessary.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Development_Methodology/index.html
32805dcbf4a7-2
If you plan on distributing Sugar custom code, then you must package your customization as a Module Loadable Package (a .zip file that includes all custom code along with a manifest file). It is easy to write a script to build a module loadable package either from custom directory content or by extracting customizations out of a development environment. See examples on Github here and here. Note: Sugar Sell Essentials customers do not have the ability to upload custom file packages to Sugar using Module Loader. In some Enterprise environments, changes are tightly controlled, and ownership of various Sugar application components may be spread across multiple teams, requiring a coordinated deployment. For example, a Database Administrator (DBA) may be responsible for implementing database schema (DDL) changes and a System Administrator may be responsible for implementing file system changes. For these situations: File system changes can be accounted for using Git to determine the difference between current production state and the latest changes to be deployed. DDL changes can be accounted for via deploying latest file system changes on a clone of Sugar production instance and running Quick Repair command. Sugar will prompt you with any DDL changes that need to be made that you can then capture and share with your DBA. Data Manipulation Language (DML) changes, if necessary, should be managed within SQL or PHP scripts. Deployment If using the traditional Git-based deployment, then deploying new Sugar code is as easy as checking out the latest branch and then running Quick Repair and Rebuild. Run the quick repair from the Sugar user interface, or script it for fully automated deployment. When deploying to an instance on Sugar's cloud service, it is necessary to install the package manually using Module Loader. It is not possible to automate the deployment of packages into instances on Sugar's cloud service.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Development_Methodology/index.html
32805dcbf4a7-3
In a coordinated deployment, database changes should be deployed first, followed by filesystem changes, followed by a Quick Repair (if permitted) to clear system caches. You can clear caches manually by deleting the contents of the ./cache/ directory and then truncate the metadata_cache table in the Sugar database. The Sugar application regenerates these caches as needed. Using Sugar Studio to deploy changes into new environments (especially Production) is not recommended. Manually re-creating customizations using the Studio user interface can be error-prone. It also runs the risk of inadvertently overwriting other code customizations. It may be initially slower to create a custom field, etc. manually using extensions on filesystem but, in the long run, you benefit from better change management and automation. Managing Multiple Environments CRMs are business-critical applications so development should never be performed directly on your production environment. A typical Sugar project involves multiple staging environments as well as individual development environments that each Sugar developer uses for actual coding. SugarCRM recommends 4 different environments: Production environment : used by real users User Acceptance Test (UAT) environment : used by business stakeholders to sign off on changes that go into production Quality Assurance environment : used for test and validation of new features and bug fixes Development environments : used by individual Sugar developers to create and test code (often running on a local laptop or PC) Code changes that flow upstream from a development environment should not be allowed into production without going through quality assurance (QA) and user acceptance testing (UAT) first. The intermediate environments serve as gates between development and production that help intercept problems before they reach production. User and CRM data that needs to flow downstream from production environment should pass through intermediate environments as well to ensure consistency and that it is cleaned or anonymized of any personally identifiable or sensitive information. Consistency
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Development_Methodology/index.html
32805dcbf4a7-4
Consistency Maintaining as much consistency as possible for each of these environments is essential. Inconsistent environments can create issues where bugs are reproducible in one environment and not others (for example, a bug that only appears in production). Many times, these bugs are traced to configuration parameters that are not directly related to Sugar or the features and customizations under development. To replicate your production environment as accurately as possible, we recommend you use VM or container technology in your development and QA environments. Your UAT environment should match the infrastructure of your production environment. SugarCRM uses a variety of container technologies in developing the core Sugar application and for working on Sugar projects. In particular, we use Virtual Box, VMWare, Amazon AMIs, Docker containers, Vagrant, and Packer. SugarCRM Engineering also uses Puppet to centrally manage the provisioning and configuration of all these different environments. Testing SugarCRM recommends using a variety of testing methods to ensure the quality of your Sugar project. Perform unit testing, functional testing (either manual or GUI automation), system integration testing, user acceptance testing, and performance testing. Unit testing should be applied to ensure that even the smallest code units within your application are behaving as expected. Functional testing should be performed to ensure that each feature and function behaves the way it was designed. System Integration testing should be performed to ensure that Sugar co-exists with external systems and that data flows between all these systems successfully. User acceptance testing should be performed by key stakeholders to ensure that your project is meeting business requirements. Performance testing should be performed to ensure that the Sugar application's responsiveness meets user expectations and that the application continues to scale. In our experience, neglecting any of these tests can negatively impact a Sugar project in terms of maintainability, customer satisfaction, and business success.  In the next section, we introduce some tools and open-source resources that can help you start a QA practice for your project.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Development_Methodology/index.html
32805dcbf4a7-5
Sugar Test Tools For Sugar customers and partners, SugarCRM provides Test Tools that can be used to verify and perform quality assurance on Sugar customizations. Use of Sugar test technology requires familiarity with PHPUnit for PHP unit testing, Jasmine for JavaScript unit testing, and Apache JMeter for performance load testing. Sugar Unit Tests The Sugar Unit Test suites are the automated unit tests developed and maintained by SugarCRM Engineering during the process of building and releasing each new Sugar release. As part of our development process, these tests are required to run "green" (100% passing) at all times on each master release branch. Essentially, these tests form a regression test suite for an uncustomized version of Sugar running in our controlled build environment. With that understanding, here is a recommended approach to take advantage of these unit tests. Run test suite against an uncustomized copy of Sugar in your development environment to establish a baseline. Not all tests may immediately pass; some may fail due to configuration differences between your development environment and SugarCRM Engineering's controlled build environment. Correct any observed failures or skip/remove the failing tests to create a base test suite that is 100% passing. As you develop customizations on Sugar, ensure that your base test suite continues to pass. Create new tests for new code customizations that you create. Sugar Performance Tests Instead of sanitizing data from a production environment for purposes of load testing, SugarCRM provides an open source tool called Tidbit that can be used to generate pseudo-random data to populate a Sugar instance with representable data. We also provide Apache JMeter scenarios to Sugar customers and partners who request access. These JMeter scenarios can be used to drive a simulated load against the Sugar REST API interface used by Sugar. They can validate that your customizations have not had an unexpected impact on the performance of a Sugar instance. DevOps
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Development_Methodology/index.html
32805dcbf4a7-6
DevOps In order to facilitate and streamline development processes, Sugar recommends implementing DevOps automation. Use a tool such as Jenkins to orchestrate test automation, stage changes in any environment (dev, QA, UAT, and prod) for manual verification, and manage the promotion of changes from one environment to the next. Perform automated tests (e.g. unit tests) on each commit. Stage development changes on at least a nightly basis for use by QA or demos. Automate the rollback of changes in any environment as needed. Automate notifications to affected and responsible parties whenever a test fails, or a build fails to deploy. Co-Existing with Studio Customizations Sugar Studio and Module Builder enable administrator users to implement quick changes to a Sugar environment. But Sugar Studio lacks the rigorous change control that larger CRM projects need. Sometimes, Studio changes can even break code-level Sugar customizations. For this reason, we often discourage using Studio on heavily customized Sugar instances. However, if Sugar Studio is an important up-front requirement for a CRM project, then there are strategies you can adopt for your customizations to avoid conflicts. Sugar Studio can be used to modify the layouts, fields, and relationships for the majority of modules in Sugar. Module Builder can be used to define new modules along with their layouts, fields, and relationships. In practice, this means that the fields and layouts for any module's record view, list view, mobile view, and subpanels can be customized using simple administration tools. Studio users, therefore, could potentially break code customizations that are reliant on a particular field or having a field on a particular layout or location. Here are some practices to avoid conflicts between Studio customizations and custom code: Avoid custom record, list, and subpanel view controllers because Studio users can change fields and layouts that affect expectations within your controller code.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Development_Methodology/index.html
32805dcbf4a7-7
Avoid custom record validations because Studio users can change fields and layouts that affect expectations within your validation code. Avoid hard-coded integrations that rely on a particular field because Studio users can change fields that affect expectations within your integration. Avoid new field and relationship vardefs customizations because Studio users can create new fields and relationships. Avoid viewdefs customizations for record, list, and subpanel layouts because Studio users perform these customizations. Many customizations have a smaller risk of side effects related to Studio customizations. Here is a list of some changes that administrator users cannot perform via Studio: Adding custom dashlets Adding custom layouts or additions to footer or header Adding custom actions in record view action dropdown Adding metadata-aware integrations that discover fields and modules on the system Adding logic hooks Conversely, certain customizations can provide Studio users with additional tools: Adding custom Sugar Logic functions Adding custom Sugar field types Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Introduction/Development_Methodology/index.html
7acb3ea93bdd-0
Cookbook Welcome to the SugarCRM Developer Cookbook! This library is filled with real-world code examples for common Sugar customizations and best practices. Sugar's DevClub is always cooking up new ideas, so be sure to check in often and see what's new. Get started by browsing the categories below.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/index.html
7acb3ea93bdd-1
TopicsAdding Buttons to the Record ViewThis example explains how to create additional buttons on the record view and add events. We will extend and override the stock Accounts record view to add a custom button. The custom button will be called "Validate Postal Code" and ping the Zippopotamus REST service to validate the records billing state and postal code.Adding Field Validation to the Record ViewThis page explains how to add additional field validation to the record view. In the following examples, we will extend and override the stock Accounts record view to add custom validation. The custom validation will require the Office Phone field when the account type is set to "Customer" and also require the user to enter at least one email address.Adding an Existing Note to an Email as AttachmentThere may be times when you want to reuse a file attached to one Note record as an attachment for an Email, similar to the ability in the Compose Email view to add an attachment using 'Sugar Document'.Adding the Email Field to a BeanThis example explains how to add an emails field for modules that don't extend the Person module template. We will create an email field and bring the email functionality module bean. The steps are applicable for stock and custom modules. In this example, we will add the email field into the Opportunities module.Converting Address' Country Field to a DropdownAddress fields in Sugar® are normally text fields, which allow users to enter in the appropriate information (e.g. street, city, and country) for the record. However, with multiple users working in Sugar, it is possible for data (e.g. country) to be entered in a variety of different ways (e.g. USA, U.S.A, and United States) when creating or editing the record. This can cause some issues when creating a report grouped by the Billing Country field, for example, as records with the same country will be grouped separately based on the different ways the country was entered.Changing the Default Module When Logging a New
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/index.html
7acb3ea93bdd-2
grouped separately based on the different ways the country was entered.Changing the Default Module When Logging a New Call or MeetingWhen creating a call or meeting directly from the Calls or Meetings module in Sugar, the default module for the Related To field is Accounts. If your sales team frequently schedules calls and meetings related to records from a module other than Accounts, it may make sense to adjust the behavior so that the Related To field defaults to a more commonly used module. This article covers how to change the default related module for calls and meetings in Sugar.Creating Custom Field TypesIn this example, we create a custom field type called "Highlightfield", which will mimic the base text field type with the added feature that the displayed text for the field will be highlighted in a color chosen when the field is created in Studio.Creating an Auto-Incrementing FieldThis article will cover the two approaches to creating an auto-incrementing field in Sugar.Customizing Prefill Fields When Copying RecordsThe copy action on the record view allows for users to duplicate records. This article will cover the various ways to customize the prefill fields on the copy view.Customizing the Email Editor ButtonsThe Emails module in Sugar® displays commonly-used buttons in the HTML editor. This article explains how to modify the buttons on the editor's toolbar.Customizing the Start Speed of List View SearchWhen searching a Sidecar module's list view, Sugar® begins returning results automatically once a predefined number of milliseconds have passed. This article covers how to customize the start speed of the list view search for Sidecar modules in Sugar.Disabling RLI Alerts on OpportunitiesHow to disable Revenue Line Item (RLI) alerts on Opportunities using a custom JavaScript controller.Disabling TooltipsThis article will demonstrate how to disable the tooltips in Sugar.Dynamically Hiding Subpanels Based on Record ValuesThis article will demonstrate how to dynamically hide subpanels that are dependent on record values by overriding the subpanels layout for a module. This example is for an account record where
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/index.html
7acb3ea93bdd-3
record values by overriding the subpanels layout for a module. This example is for an account record where we will hide the Contacts subpanel when the account type is not 'Customer'.Enabling Importing for Custom ModulesWhen designing a custom module in Module Builder, you have the option to enable importing for the module. If the custom module is deployed without enabling this option, it is not recommended that you redeploy the module since any changes made in Studio and potentially other areas of the application could be lost. This article will cover how to enable importing for custom modules via a code-level change to preserve any additional configurations made to the module since being deployed from Module Builder.Increasing the Number of Dashboards Displayed in the Home MenuBy default, the "Home Dashboard" comes out-of-the-box with Sugar® to display on the home page. In addition, Sugar users with a Sugar Serve and/or Sugar Sell license type will have access to specialized Home page dashboards called "Service Console" and "Renewals Console". Users have the ability to create new dashboards on their home page and build out its layout and dashlet set. Currently, Sugar imposes a limit of 50 dashboards that can be displayed under the Home module tab. So, when creating multiple dashboards, keep in mind that having more than 50 in the list of available dashboards will cause the ones in the beginning to be dropped off the list. This article covers how to increase the number of dashboards allowed in the Home menu via a code-level customization.Logic HooksThese pages demonstrate some common examples of working with logic hooks in Sugar.Modifying Calendar Item ColorsEach calendar event type (Meetings, Calls, and Tasks) has its own distinct color scheme. This article will review how to modify these colors, as well as demonstrate how to set the event color based on the event status.Modifying Layouts to Display Additional ColumnsBy default, the record view layout for each module displays two columns of fields. The number of
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/index.html
7acb3ea93bdd-4
ColumnsBy default, the record view layout for each module displays two columns of fields. The number of columns to display can be customized on a per-module basis with the following steps.Modifying Subpanel ButtonsSeveral buttons exist on each subpanel by default such as "Create" (+ Plus symbol) and "Link Existing Record". These buttons are controlled by the panel-top view for each module. To make changes to the buttons included in a subpanel layout, you will need to create an override for the panel-top view in ./custom/Extension/modules/<module>/Ext/clients/base/views/panel-top/ and update the corresponding buttons property to include or exclude a button.Module Loadable PackagesExamples working with the module loadable packages.Moving Footer content to Sidebar NavThis example explains how to add additional buttons to a new section in the sidebar nav layout. You may have previously customized a button that was added to the footer layout, which can be repurposed here and added to the sidebar-nav layout. We will create a custom view and append the view component to the sidebar-nav layout metadata. The additional button will merely show an alert and a flyout menu with a link to the Accounts module but can be expanded to do much more.Passing Data to TemplatesThis page explains how to create a custom view component that passes data to the Handlebars template.Prepopulating the Compose Email ViewWhen composing an email in Sugar, it may be useful to modify the compose view to better suit your common business practices. In this article, we will use JavaScript to create a code-level customization which causes the To, CC, and Subject fields of the email to prepopulate with data from a related Opportunity.Refreshing Subpanels on the RecordViewHow to refresh specific subpanels on the Record View.Removing the Account Requirement on OpportunitiesThis article covers how to remove the Account field from being required on the Opportunities module.Web ServicesExamples when working with Sugar's web service endpoints.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/index.html
7acb3ea93bdd-5
Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/index.html
2417d3f18db5-0
Adding the Email Field to a Bean Overview This example explains how to add an emails field for modules that don't extend the Person module template. We will create an email field and bring the email functionality module bean. The steps are applicable for stock and custom modules. In this example, we will add the email field into the Opportunities module. Steps to Complete This tutorial requires the following steps, which are explained in the sections below: Creating a Custom Vardef file for email Field and Relationships Creating a Custom Bean and Modify the save function Replacing the stock bean with the custom bean Adding Emails Field into Record View Creating a Custom Vardef file for email Field and Relationships You will create a file in the custom/Extension/modules/Opportunities/ folder for the field and relationships definitions. ./custom/Extension/modules/Opportunities/Ext/Vardefs/custom_email_field.php <?php $module = 'Opportunity'; $table_name = 'opportunities'; $dictionary[$module]['fields']['email'] = array( 'name' => 'email', 'type' => 'email', 'query_type' => 'default', 'source' => 'non-db', 'operator' => 'subquery', 'subquery' => 'SELECT eabr.bean_id FROM email_addr_bean_rel eabr JOIN email_addresses ea ON (ea.id = eabr.email_address_id) WHERE eabr.deleted=0 AND ea.email_address LIKE', 'db_field' => array( 'id', ), 'vname' => 'LBL_EMAIL_ADDRESS', 'studio' => array( 'visible' => true, 'searchview' => true, 'editview' => true, 'editField' => true, ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-1
'editField' => true, ), 'duplicate_on_record_copy' => 'always', 'len' => 100, 'link' => 'email_addresses_primary', 'rname' => 'email_address', 'module' => 'EmailAddresses', 'full_text_search' => array( 'enabled' => true, 'searchable' => true, 'boost' => 1.50, ), 'audited' => true, 'pii' => true, ); $dictionary[$module]['fields']['email1'] = array( 'name' => 'email1', 'vname' => 'LBL_EMAIL_ADDRESS', 'type' => 'varchar', 'function' => array( 'name' => 'getEmailAddressWidget', 'returns' => 'html', ), 'source' => 'non-db', 'link' => 'email_addresses_primary', 'rname' => 'email_address', 'group' => 'email1', 'merge_filter' => 'enabled', 'module' => 'EmailAddresses', 'studio' => false, 'duplicate_on_record_copy' => 'always', 'importable' => false, ); $dictionary[$module]['fields']['email2'] = array( 'name' => 'email2', 'vname' => 'LBL_OTHER_EMAIL_ADDRESS', 'type' => 'varchar', 'function' => array( 'name' => 'getEmailAddressWidget', 'returns' => 'html', ), 'source' => 'non-db', 'group' => 'email2',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-2
'source' => 'non-db', 'group' => 'email2', 'merge_filter' => 'enabled', 'studio' => 'false', 'duplicate_on_record_copy' => 'always', 'importable' => false, 'workflow' => false, ); $dictionary[$module]['fields']['invalid_email'] = array( 'name' => 'invalid_email', 'vname' => 'LBL_INVALID_EMAIL', 'source' => 'non-db', 'type' => 'bool', 'link' => 'email_addresses_primary', 'rname' => 'invalid_email', 'massupdate' => false, 'studio' => 'false', 'duplicate_on_record_copy' => 'always', ); $dictionary[$module]['fields']['email_opt_out'] = array( 'name' => 'email_opt_out', 'vname' => 'LBL_EMAIL_OPT_OUT', 'source' => 'non-db', 'type' => 'bool', 'link' => 'email_addresses_primary', 'rname' => 'opt_out', 'massupdate' => false, 'studio' => 'false', 'duplicate_on_record_copy' => 'always', ); $dictionary[$module]['fields']['email_addresses_primary'] = array( 'name' => 'email_addresses_primary', 'type' => 'link', 'relationship' => strtolower($table_name) . '_email_addresses_primary', 'source' => 'non-db', 'vname' => 'LBL_EMAIL_ADDRESS_PRIMARY', 'duplicate_merge' => 'disabled', 'primary_only' => true, );
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-3
'primary_only' => true, ); $dictionary[$module]['fields']['email_addresses'] = array( 'name' => 'email_addresses', 'type' => 'link', 'relationship' => strtolower($table_name) . '_email_addresses', 'source' => 'non-db', 'vname' => 'LBL_EMAIL_ADDRESSES', 'reportable' => false, 'unified_search' => true, 'rel_fields' => array('primary_address' => array('type' => 'bool')), ); // Used for non-primary mail import $dictionary[$module]['fields']['email_addresses_non_primary'] = array( 'name' => 'email_addresses_non_primary', 'type' => 'varchar', 'source' => 'non-db', 'vname' => 'LBL_EMAIL_NON_PRIMARY', 'studio' => false, 'reportable' => false, 'massupdate' => false, ); $dictionary[$module]['relationships'][strtolower($table_name) . '_email_addresses'] = array( 'lhs_module' => $table_name, 'lhs_table' => strtolower($table_name), 'lhs_key' => 'id', 'rhs_module' => 'EmailAddresses', 'rhs_table' => 'email_addresses', 'rhs_key' => 'id', 'relationship_type' => 'many-to-many', 'join_table' => 'email_addr_bean_rel', 'join_key_lhs' => 'bean_id', 'join_key_rhs' => 'email_address_id', 'relationship_role_column' => 'bean_module', 'relationship_role_column_value' => $table_name, );
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-4
'relationship_role_column_value' => $table_name, ); $dictionary[$module]['relationships'][strtolower($table_name) . '_email_addresses_primary'] = array( 'lhs_module' => $table_name, 'lhs_table' => strtolower($table_name), 'lhs_key' => 'id', 'rhs_module' => 'EmailAddresses', 'rhs_table' => 'email_addresses', 'rhs_key' => 'id', 'relationship_type' => 'many-to-many', 'join_table' => 'email_addr_bean_rel', 'join_key_lhs' => 'bean_id', 'join_key_rhs' => 'email_address_id', 'relationship_role_column' => 'bean_module', 'relationship_role_column_value' => $module, 'primary_flag_column' => 'primary_address', ); Creating a Custom Bean and Modifying the Save Function Next step, you will need to create a custom bean that extends from the stock bean. In our example, we choose the Opportunities.  ./custom/modules/Opportunities/CustomOpportunity.php <?php class CustomOpportunity extends Opportunity { /** * Constructor */ public function __construct() { parent::__construct(); $this->emailAddress = BeanFactory::newBean('EmailAddresses'); } /** * Populate email address fields here instead of retrieve() so that they are properly available for logic hooks * * @see parent::fill_in_relationship_fields() */ public function fill_in_relationship_fields() { parent::fill_in_relationship_fields(); $this->emailAddress->handleLegacyRetrieve($this); } /** * @see parent::get_list_view_data()
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-5
} /** * @see parent::get_list_view_data() */ public function get_list_view_data() { global $current_user; $temp_array = $this->get_list_view_array(); $temp_array['EMAIL'] = $this->emailAddress->getPrimaryAddress($this); // Fill in the email1 field only if the user has access to it // This is a special case, because getEmailLink() uses email1 field for making the link // Otherwise get_list_view_data() shouldn't set any fields except fill the template data if ($this->ACLFieldAccess('email1', 'read')) { $this->email1 = $temp_array['EMAIL']; } $temp_array['EMAIL_LINK'] = $current_user->getEmailLink('email1', $this, '', '', 'ListView'); return $temp_array; } /** * * @see parent::save() */ public function save($check_notify = false) { if (static::inOperation('saving_related')) { parent::save($check_notify); return $this; } $ori_in_workflow = empty($this->in_workflow) ? false : true; $this->emailAddress->handleLegacySave($this, $this->module_dir); parent::save($check_notify); $override_email = array(); if (!empty($this->email1_set_in_workflow)) { $override_email['emailAddress0'] = $this->email1_set_in_workflow; } if (!empty($this->email2_set_in_workflow)) { $override_email['emailAddress1'] = $this->email2_set_in_workflow;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-6
$override_email['emailAddress1'] = $this->email2_set_in_workflow; } if (!isset($this->in_workflow)) { $this->in_workflow = false; } if ($ori_in_workflow === false || !empty($override_email)) { $result = $this->emailAddress->save($this->id, $this->module_dir, $override_email, '', '', '', '', $this->in_workflow); } return $this; } } Replacing the Stock Bean with a Custom Bean Once you created the custom bean, you will need to show Sugar to use Custom bean. To do that you will create ./custom/modules/<modulename>/<modulename>.php and update the class name and file path in the $beanList and $beanFiles. (See: Modules $beanList and Customizing Core SugarBeans) custom/Extension/application/Ext/Include/customOpportunities.php <?php $objectList['Opportunities'] = 'Opportunity'; $beanList['Opportunities'] = 'CustomOpportunity'; $beanFiles['CustomOpportunity'] = 'custom/modules/Opportunities/CustomOpportunity.php'; Once you have created these files, you will need to navigate Admin > Repairs and perform Quick Repair and Rebuild. Adding the Emails Field to the Record View At the stage, you have already created the field and updated the bean. The last step is placing the email field to record view. You can perform this step using Studio. Once you navigate to Studio you will find an Email field on the left column where available fields are listed. After adding the field the record views of Opportunities will look like this: ./custom/modules/Opportunities/clients/base/views/record/record.php <?php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-7
./custom/modules/Opportunities/clients/base/views/record/record.php <?php $viewdefs['Opportunities'] = array ( 'base' => array ( 'view' => array ( 'record' => array ( 'buttons' => array ( 0 => array ( 'type' => 'button', 'name' => 'cancel_button', 'label' => 'LBL_CANCEL_BUTTON_LABEL', 'css_class' => 'btn-invisible btn-link', 'showOn' => 'edit', 'events' => array ( 'click' => 'button:cancel_button:click', ), ), 1 => array ( 'type' => 'rowaction', 'event' => 'button:save_button:click', 'name' => 'save_button', 'label' => 'LBL_SAVE_BUTTON_LABEL', 'css_class' => 'btn btn-primary', 'showOn' => 'edit', 'acl_action' => 'edit', ), 2 => array ( 'type' => 'actiondropdown', 'name' => 'main_dropdown', 'primary' => true, 'showOn' => 'view', 'buttons' => array ( 0 => array ( 'type' => 'rowaction', 'event' => 'button:edit_button:click', 'name' => 'edit_button', 'label' => 'LBL_EDIT_BUTTON_LABEL', 'acl_action' => 'edit', ), 1 =>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-8
'acl_action' => 'edit', ), 1 => array ( 'type' => 'shareaction', 'name' => 'share', 'label' => 'LBL_RECORD_SHARE_BUTTON', 'acl_action' => 'view', ), 2 => array ( 'type' => 'pdfaction', 'name' => 'download-pdf', 'label' => 'LBL_PDF_VIEW', 'action' => 'download', 'acl_action' => 'view', ), 3 => array ( 'type' => 'pdfaction', 'name' => 'email-pdf', 'label' => 'LBL_PDF_EMAIL', 'action' => 'email', 'acl_action' => 'view', ), 4 => array ( 'type' => 'divider', ), 5 => array ( 'type' => 'rowaction', 'event' => 'button:find_duplicates_button:click', 'name' => 'find_duplicates_button', 'label' => 'LBL_DUP_MERGE', 'acl_action' => 'edit', ), 6 => array ( 'type' => 'rowaction', 'event' => 'button:duplicate_button:click', 'name' => 'duplicate_button', 'label' => 'LBL_DUPLICATE_BUTTON_LABEL', 'acl_module' => 'Opportunities', 'acl_action' => 'create', ), 7 => array ( 'type' => 'rowaction',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-9
7 => array ( 'type' => 'rowaction', 'event' => 'button:historical_summary_button:click', 'name' => 'historical_summary_button', 'label' => 'LBL_HISTORICAL_SUMMARY', 'acl_action' => 'view', ), 8 => array ( 'type' => 'rowaction', 'event' => 'button:audit_button:click', 'name' => 'audit_button', 'label' => 'LNK_VIEW_CHANGE_LOG', 'acl_action' => 'view', ), 9 => array ( 'type' => 'divider', ), 10 => array ( 'type' => 'rowaction', 'event' => 'button:delete_button:click', 'name' => 'delete_button', 'label' => 'LBL_DELETE_BUTTON_LABEL', 'acl_action' => 'delete', ), ), ), 3 => array ( 'name' => 'sidebar_toggle', 'type' => 'sidebartoggle', ), ), 'panels' => array ( 0 => array ( 'name' => 'panel_header', 'header' => true, 'fields' => array ( 0 => array ( 'name' => 'picture', 'type' => 'avatar', 'size' => 'large', 'dismiss_label' => true, 'readonly' => true, ), 1 => array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-10
), 1 => array ( 'name' => 'name', 'related_fields' => array ( 0 => 'total_revenue_line_items', 1 => 'closed_revenue_line_items', 2 => 'included_revenue_line_items', ), ), 2 => array ( 'name' => 'favorite', 'label' => 'LBL_FAVORITE', 'type' => 'favorite', 'dismiss_label' => true, ), 3 => array ( 'name' => 'follow', 'label' => 'LBL_FOLLOW', 'type' => 'follow', 'readonly' => true, 'dismiss_label' => true, ), ), ), 1 => array ( 'name' => 'panel_body', 'label' => 'LBL_RECORD_BODY', 'columns' => 2, 'labels' => true, 'labelsOnTop' => true, 'placeholders' => true, 'newTab' => false, 'panelDefault' => 'expanded', 'fields' => array ( 0 => array ( 'name' => 'account_name', 'related_fields' => array ( 0 => 'account_id', ), ), 1 => array ( 'name' => 'date_closed', 'related_fields' => array ( 0 => 'date_closed_timestamp', ), ), 2 => array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-11
), ), 2 => array ( 'name' => 'amount', 'type' => 'currency', 'label' => 'LBL_LIKELY', 'related_fields' => array ( 0 => 'amount', 1 => 'currency_id', 2 => 'base_rate', ), 'currency_field' => 'currency_id', 'base_rate_field' => 'base_rate', 'span' => 12, ), 3 => array ( 'name' => 'best_case', 'type' => 'currency', 'label' => 'LBL_BEST', 'related_fields' => array ( 0 => 'best_case', 1 => 'currency_id', 2 => 'base_rate', ), 'currency_field' => 'currency_id', 'base_rate_field' => 'base_rate', ), 4 => array ( 'name' => 'worst_case', 'type' => 'currency', 'label' => 'LBL_WORST', 'related_fields' => array ( 0 => 'worst_case', 1 => 'currency_id', 2 => 'base_rate', ), 'currency_field' => 'currency_id', 'base_rate_field' => 'base_rate', ), 5 => array ( 'name' => 'tag', 'span' => 6, ), 6 => array ( 'name' => 'sales_status', 'readonly' => true,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-12
'name' => 'sales_status', 'readonly' => true, 'studio' => true, 'label' => 'LBL_SALES_STATUS', 'span' => 6, ), 7 => array ( 'name' => 'email', 'studio' => array ( 'visible' => true, 'searchview' => true, 'editview' => true, 'editField' => true, ), 'label' => 'LBL_EMAIL_ADDRESS', 'span' => 12, ), ), ), 2 => array ( 'name' => 'panel_hidden', 'label' => 'LBL_RECORD_SHOWMORE', 'hide' => true, 'labelsOnTop' => true, 'placeholders' => true, 'columns' => 2, 'newTab' => false, 'panelDefault' => 'expanded', 'fields' => array ( 0 => 'next_step', 1 => 'opportunity_type', 2 => 'lead_source', 3 => 'campaign_name', 4 => array ( 'name' => 'description', 'span' => 12, ), 5 => 'assigned_user_name', 6 => 'team_name', 7 => array ( 'name' => 'date_entered_by', 'readonly' => true, 'type' => 'fieldset', 'label' => 'LBL_DATE_ENTERED', 'fields' => array ( 0 =>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2417d3f18db5-13
'fields' => array ( 0 => array ( 'name' => 'date_entered', ), 1 => array ( 'type' => 'label', 'default_value' => 'LBL_BY', ), 2 => array ( 'name' => 'created_by_name', ), ), ), 8 => array ( 'name' => 'date_modified_by', 'readonly' => true, 'type' => 'fieldset', 'label' => 'LBL_DATE_MODIFIED', 'fields' => array ( 0 => array ( 'name' => 'date_modified', ), 1 => array ( 'type' => 'label', 'default_value' => 'LBL_BY', ), 2 => array ( 'name' => 'modified_by_name', ), ), ), ), ), ), 'templateMeta' => array ( 'useTabs' => false, ), ), ), ), ); Once the files are in place, navigate to Admin > Repair > Quick Repair & Rebuild to regenerate the metadata. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_the_Email_Field_to_a_Bean/index.html
2134b56d72fd-0
Enabling Importing for Custom Modules Overview When designing a custom module in Module Builder, you have the option to enable importing for the module. If the custom module is deployed without enabling this option, it is not recommended that you redeploy the module since any changes made in Studio and potentially other areas of the application could be lost. This article will cover how to enable importing for custom modules via a code-level change to preserve any additional configurations made to the module since being deployed from Module Builder. Steps to Complete To enable importing for your custom module, you must modify certain PHP files depending on the version of Sugar that you have. Please note that the instructions below apply to custom modules created via Admin > Module Builder and are not applicable to any stock modules which come out-of-the-box with Sugar. All of the directory paths are relative to the root directory of Sugar on the web server and require you to replace the <module_key> and <module_name> variables with appropriate values for your situation. For instance, if your module is installed in the directory of ./modules/abc_custom_module/ then the <module_key> would be abc and <module_name> would be custom_module. Edit the ./modules/<module_key>_<module_name>/<module_key>_<module_name>_sugar.php file in your Sugar file system. Around line 24 of the file, locate and change public $importable = false; to public $importable = true;. Save your changes to the file. Next, edit the ./modules/<module_key>_<module_name>/clients/base/menus/header/header.php file which should look similar to this:$viewdefs[$moduleName]['base']['menu']['header'] = array( array( 'route' => "#$moduleName/create", 'label' => 'LNK_NEW_RECORD', 'acl_action' => 'create',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Enabling_Importing_for_Custom_Modules/index.html
2134b56d72fd-1
'acl_action' => 'create', 'acl_module' => $moduleName, 'icon' => 'fa-plus', ), array( 'route' => "#$moduleName", 'label' => 'LNK_LIST', 'acl_action' => 'list', 'acl_module' => $moduleName, 'icon' => 'fa-bars', ), ); Add the following line to the end of the file after the last  ), but before the ending );:array( 'route' => "#bwc/index.php?module=Import&action=Step1&import_module=$moduleName&return_module=$moduleName&return_action=index", 'label' => 'LBL_IMPORT', 'acl_action' => 'import', 'acl_module' => $moduleName, 'icon' => 'icon-upload', ), Save your changes to the file. The updated file should then look similar to this:$viewdefs[$moduleName]['base']['menu']['header'] = array( array( 'route' => "#$moduleName/create", 'label' => 'LNK_NEW_RECORD', 'acl_action' => 'create', 'acl_module' => $moduleName, 'icon' => 'fa-plus', ), array( 'route' => "#$moduleName", 'label' => 'LNK_LIST', 'acl_action' => 'list', 'acl_module' => $moduleName, 'icon' => 'fa-bars', ), array( 'route' => "#bwc/index.php?module=Import&action=Step1&import_module=$moduleName&return_module=$moduleName&return_action=index", 'label' => 'LBL_IMPORT',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Enabling_Importing_for_Custom_Modules/index.html
2134b56d72fd-2
'label' => 'LBL_IMPORT', 'acl_action' => 'import', 'acl_module' => $moduleName, 'icon' => 'icon-upload', ), ); Once the necessary changes have been made, log into Sugar and navigate to Admin > Repair and perform a "Quick Repair and Rebuild". This will rebuild the cached files to fully implement the changes.  Application After making these changes, the "Import {Module Name}" option will appear in the Actions menu of the custom module's module tab. Simply click the triangle in the module tab, then select the Import option to create or update records for your custom module. For instructions on using Sugar's Import tool, please refer to the Import documentation.   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Enabling_Importing_for_Custom_Modules/index.html
c1a45864f603-0
Modifying Layouts to Display Additional Columns Overview By default, the record view layout for each module displays two columns of fields. The number of columns to display can be customized on a per-module basis with the following steps. Resolution First, you will want to ensure your layouts are deployed in the custom directory. If you have not previously customized your layouts via Studio, go to Admin > Studio > {Module Name} > Layouts. From there, select each layout you wish to add additional columns to and click 'Save & Deploy'. This action will create a corresponding layout file under the ./custom/modules/{Module Name}/clients/base/views/record/ directory. The file will be named record.php. In your custom record.php file, locate the maxColumns value under templateMeta array, and change it to the number of columns you would like to have on screen: 'maxColumns' => '3', Once that is updated, locate the widths array to define the spacing for your each column(s). You should have a label and field entry for each column in your layout: 'widths' => array ( 0 => array ( 'label' => '10', 'field' => '30', ), 1 => array ( 'label' => '10', 'field' => '30', ), 2 => array ( 'label' => '10', 'field' => '30', ), ), Next, under the existing panels array, each entry will already have a columns property, with a value of 2. Update each of these to the number of columns you set for maxColumns : 'columns' => 3,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Modifying_Layouts_to_Display_Additional_Columns/index.html
c1a45864f603-1
'columns' => 3, Once the file has been modified, you can navigate to Studio and add fields to your new column in the layout. For any rows that already contain two fields, the second field will automatically span the second and third column. Simply click the minus (-) icon to contract the field to one column and expose the new column space: After you have added the desired fields in Studio, click 'Save & Deploy' to finalize your changes Column Widths Studio does not support expanding a field beyond two column-widths. If you want a field to span the full layout (all three columns), you would need to manually update this in the custom record.php like so: array ( 'name' => 'description', 'span' => 12, ) Changing the span value from 8 to 12. After saving the changes on the file, you would then run a Quick Repair and Rebuild. However, any updates in Studio will revert the span back to 8.   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Modifying_Layouts_to_Display_Additional_Columns/index.html
dcd716c1355a-0
Customizing the Email Editor Buttons Overview The Emails module in Sugar® displays commonly-used buttons in the HTML editor. This article explains how to modify the buttons on the editor's toolbar. Modifying The View The following sections outline how to customize the button toolbar presented within the TinyMCE editor. In the example below, we will be adding buttons for Cut, Copy, and Paste to the toolbar. Using Custom Module Metadata To override the Emails module compose-email view, we will need to copy ./modules/Emails/clients/base/views/compose-email/compose-email.php to ./custom/modules/Emails/clients/base/views/compose-email/compose-email.php. Once completed, we will then edit the ['tinyConfig']['toolbar'] definition to include | cut copy paste . An example of this is shown below: ./custom/modules/Emails/clients/base/views/compose-email/compose-email.php $viewdefs['Emails']['base']['view']['compose-email'] = array( ... 'panels' => array( array( ... 'fields' => array( ... array( 'name' => 'description_html', 'dismiss_label' => true, 'span' => 12, 'tinyConfig' => array( 'toolbar' => 'code | bold italic underline strikethrough | bullist numlist | ' . 'alignleft aligncenter alignright alignjustify | forecolor backcolor | ' . 'fontsizeselect | formatselect | fontselect | sugarattachment sugarsignature sugartemplate | cut copy paste', ), ), ), ), ... ), );
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Customizing_the_Email_Editor_Buttons/index.html
dcd716c1355a-1
), ), ), ), ... ), ); Note: We recommend modifying the modules custom metadata for local deployments when the customization is not part of a distributed package. Once this file is in place, navigate to Admin > Repair > Quick Repair and Rebuild. Once completed, your changes will be reflected in the system. Using The Module Extension Framework To extend the Emails module compose-email view using the extension framework, we will need to loop through the existing views array definition to find and modify the description_html field and update the relevant sub-array ['tinyConfig']['toolbar'] with the additional toolbar buttons we want to display. An example of this is shown below: ./custom/Extension/modules/Emails/Ext/clients/base/views/compose-email/add_toolbar_buttons.php <?php $target_view = 'compose-email'; $target_fieldname = 'description_html'; $default_toolbar = 'code | bold italic underline strikethrough | bullist numlist | ' . 'alignleft aligncenter alignright alignjustify | forecolor backcolor | ' . 'fontsizeselect | formatselect | fontselect | sugarattachment sugarsignature sugartemplate'; $custom_toolbar = ' | cut copy paste'; if (!empty($viewdefs['Emails']['base']['view'][$target_view]['panels'])) { $panels = $viewdefs['Emails']['base']['view'][$target_view]['panels']; foreach ($panels as $i => $panel) { if (!empty($panel['fields'])) { foreach ($panel['fields'] as $j => $field) { if ($field['name'] == $target_fieldname) { if(!isset($field['tinyConfig'])){
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Customizing_the_Email_Editor_Buttons/index.html
dcd716c1355a-2
if(!isset($field['tinyConfig'])){ $field['tinyConfig'] = array(); } /* If toolbar already exists, add our custom buttons to the end, otherwise set it to the default and append that. */ if(!isset($field['tinyConfig']['toolbar'])) { $field['tinyConfig']['toolbar'] = $default_toolbar; } $viewdefs['Emails']['base']['view'][$target_view]['panels'][$i]['fields'][$j]['tinyConfig']['toolbar'] = $field['tinyConfig']['toolbar'] . $custom_toolbar; } } } } } Note: We recommend using the extension framework when the code will be installed as part of a distributed package.  Once this file is in place, navigate to Admin > Repair > Quick Repair and Rebuild. Once completed, your changes will be reflected in the system. Toolbar Format As demonstrated in the examples above, the toolbar value is a string with the button keywords space-separated. The | indicates a divider should be shown in the editor. If the goal were to replace the toolbar buttons with only text-modifier buttons, the value for toolbar would be: 'bold italic | underline strikethrough' The toolbar button keywords are documented at TinyMCE Editor Control Identifiers. Note that at this time, only control keywords listed as "Core" are supported by Sugar®. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Customizing_the_Email_Editor_Buttons/index.html
d75220ed0d8d-0
Customizing Prefill Fields When Copying Records Overview The copy action on the record view allows for users to duplicate records. This article will cover the various ways to customize the prefill fields on the copy view. Modifying the Copy Prefill View Using the Vardefs The following section will outline how to modify the fields that are prefilled when copying a Bug record from the record view using the beans Vardefs. This is helpful when the list of copied fields are static and have no dependencies. You can apply this to any module in the system. ./custom/Extension/modules/Bugs/Ext/Vardefs/copyPrefill.php <?php //remove a field from copy $dictionary['Bug']['fields']['description']['duplicate_on_record_copy'] = 'no'; //add a field to copy $dictionary['Bug']['fields']['priority']['duplicate_on_record_copy'] = 'always'; Once in place, navigate to Admin > Repair > Quick Repair & Rebuild. Note: You can name the file 'copyPrefill.php' anything you like. We advise against making these changes in the ./custom/Extension/modules/<module>/Ext/Vardefs/sugarfield_<field>.php files as these changes may be removed during studio edits. Modifying the Copy Prefill View Using JavaScript Controllers The following section will outline how to modify the fields that are prefilled when copying a Bug record from the record view using the JavaScript Controller. This is helpful when you need to dependently determine the fields to copy by a field on the bean. You can apply this to any module in the system. ./custom/modules/Bugs/clients/base/views/record/record.js ({ extendsFrom: 'RecordView', setupDuplicateFields: function (prefill) { this._super('setupDuplicateFields', prefill); var fields = [ 'name',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Customizing_Prefill_Fields_When_Copying_Records/index.html
d75220ed0d8d-1
var fields = [ 'name', 'assigned_user_id', 'priority', 'type', 'product_category', 'description' ]; //determines whether the field list above is a set of allowlisted (allowed) or denylisted (denied) fields var denylist = false; if (denylist) { _.each(fields, function (field) { if (field && prefill.has(field)) { //set denylist field to the default value if exists if (!_.isUndefined(prefill.fields[field]) && !_.isUndefined(prefill.fields[field].default)) { prefill.set(field, prefill.fields[field].default); } else { prefill.unset(field); } } }); } else { _.each(prefill.fields, function (value, field) { if (!_.contains(fields, field)) { if (!_.isUndefined(prefill.fields[field].default)) { prefill.set(field, prefill.fields[field].default); } else { prefill.unset(field); } } }); } } }) Once in place, navigate to Admin > Repair > Quick Repair & Rebuild. The denylist variable will determine whether the list of fields are allowlisted or denylisted from the copy feature. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Customizing_Prefill_Fields_When_Copying_Records/index.html
2def67946c61-0
Adding Field Validation to the Record View Overview This page explains how to add additional field validation to the record view. In the following examples, we will extend and override the stock Accounts record view to add custom validation. The custom validation will require the Office Phone field when the account type is set to "Customer" and also require the user to enter at least one email address. Error Messages When throwing a validation error, Sugar has several stock messages you may choose to use. They are shown below: Error Key Label Description maxValue ERROR_MAXVALUE This maximum value of this field minValue ERROR_MINVALUE This minimum value of this field maxLength ERROR_MAX_FIELD_LENGTH The max length of this field minLength ERROR_MIN_FIELD_LENGTH The min length of this field datetime ERROR_DATETIME This field requires a valid date required ERROR_FIELD_REQUIRED This field is required email ERROR_EMAIL There is an invalid email address primaryEmail ERROR_PRIMARY_EMAIL No primary email address is set duplicateEmail ERROR_DUPLICATE_EMAIL There is a duplicate email address number ERROR_NUMBER This field requires a valid number isBefore ERROR_IS_BEFORE The date of this field can not be after another date isAfter ERROR_IS_AFTER The date of this field can not be before another date You also have the option of displaying multiple error messages at a time. The example below would throw an error message notifying the user that the selected field is required and that it is also not a number. errors['<field name>'] = errors['<field name>'] || {}; errors['<field name>'].required = true; errors['<field name>'].number = true; Custom Error Messages
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_Field_Validation_to_the_Record_View/index.html
2def67946c61-1
errors['<field name>'].number = true; Custom Error Messages Custom error message can be used by appending custom language keys to app.error.errorName2Keys when initializing an extended controller. To accomplish this, create a new language key in the $app_strings. An example of this is shown below: ./custom/Extension/application/Ext/Language/en_us.error_custom_message.php <?php $app_strings['ERROR_CUSTOM_MESSAGE'] = 'My custom error message.'; Next, you will need to update your controller to use the new language key. To accomplish this, add your custom language key to the app.error.errorName2Keys array in the initialize method: initialize: function (options) { this._super('initialize', [options]); //add custom message key app.error.errorName2Keys['custom_message'] = 'ERROR_CUSTOM_MESSAGE'; .... }, Once completed, you can call your custom message by setting the app.error.errorName2Keys entry to true as shown below: errors['phone_office'] = errors['phone_office'] || {}; errors['phone_office'].custom_message = true; Method 1: Extending the RecordView and CreateView Controllers One way to validate fields on record view is by creating record and create view controllers. This method requires a duplication of code due to the hierarchy design, however, it does organize the code by module and extend the core functionality. To accomplish this, override and extend the create view controller. This handles the validation when a user is creating a new record. Once the controller has been properly extended, define the validation check and use the model.addValidationTask method to append your function to the save validation. ./custom/modules/Accounts/clients/base/views/create/create.js ({ extendsFrom: 'CreateView',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_Field_Validation_to_the_Record_View/index.html
2def67946c61-2
({ extendsFrom: 'CreateView', initialize: function (options) { this._super('initialize', [options]); //add validation tasks this.model.addValidationTask('check_account_type', _.bind(this._doValidateCheckType, this)); this.model.addValidationTask('check_email', _.bind(this._doValidateEmail, this)); }, _doValidateCheckType: function(fields, errors, callback) { //validate type requirements if (this.model.get('account_type') == 'Customer' && _.isEmpty(this.model.get('phone_office'))) { errors['phone_office'] = errors['phone_office'] || {}; errors['phone_office'].required = true; } callback(null, fields, errors); }, _doValidateEmail: function(fields, errors, callback) { //validate email requirements if (_.isEmpty(this.model.get('email'))) { errors['email'] = errors['email'] || {}; errors['email'].required = true; } callback(null, fields, errors); }, }) Next, duplicate the validation logic for the record view. This handles the validation when editing existing records. ./custom/modules/Accounts/clients/base/views/record/record.js ({ /* because 'accounts' already has a record view, we need to extend it */ extendsFrom: 'AccountsRecordView', initialize: function (options) { this._super('initialize', [options]); //add validation tasks this.model.addValidationTask('check_account_type', _.bind(this._doValidateCheckType, this)); this.model.addValidationTask('check_email', _.bind(this._doValidateEmail, this)); },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_Field_Validation_to_the_Record_View/index.html
2def67946c61-3
}, _doValidateCheckType: function(fields, errors, callback) { //validate requirements if (this.model.get('account_type') == 'Customer' && _.isEmpty(this.model.get('phone_office'))) { errors['phone_office'] = errors['phone_office'] || {}; errors['phone_office'].required = true; } callback(null, fields, errors); }, _doValidateEmail: function(fields, errors, callback) { //validate email requirements if (_.isEmpty(this.model.get('email'))) { errors['email'] = errors['email'] || {}; errors['email'].required = true; } callback(null, fields, errors); }, }) Once the files are in place, navigate to Admin > Repair > Quick Repair and Rebuild. More information on displaying custom error messages can be found in the Error Messages section. Method 2: Overriding the RecordView and CreateView Layouts Another method for defining your own custom validation is to override a module's record and create layouts to append a new view with your logic. The benefits of this method are that you can use the single view to house the validation logic, however, this means that you will have to override the layout. When overriding a layout, verify that the layout has not changed when upgrading your instance. Once the layouts are overridden, define the validation check and use the model.addValidationTask method to append the function to the save validation.  First, create the custom view. For the accounts example, create the view validate-account: ./custom/modules/Accounts/clients/base/views/validate-account/validate-account.js  ({ className:"hidden", _render: function() { //No-op, Do nothing here },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_Field_Validation_to_the_Record_View/index.html
2def67946c61-4
_render: function() { //No-op, Do nothing here }, bindDataChange: function() { //add validation tasks this.model.addValidationTask('check_account_type', _.bind(this._doValidateCheckType, this)); this.model.addValidationTask('check_email', _.bind(this._doValidateEmail, this)); }, _doValidateCheckType: function(fields, errors, callback) { //validate type requirements if (this.model.get('account_type') == 'Customer' && _.isEmpty(this.model.get('phone_office'))) { errors['phone_office'] = errors['phone_office'] || {}; errors['phone_office'].required = true; } callback(null, fields, errors); }, _doValidateEmail: function(fields, errors, callback) { //validate email requirements if (_.isEmpty(this.model.get('email'))) { errors['email'] = errors['email'] || {}; errors['email'].required = true; } callback(null, fields, errors); }, }) More information on displaying custom error messages can be found in the Error Messages section. Next, depending on the selected module, duplicate its create layout to the modules custom folder to handle record creation. In our Accounts example, we have an existing ./modules/Accounts/clients/base/layouts/create/create.php file so we need to duplicate this file to ./custom/modules/Accounts/clients/base/layouts/create/create.php. After this has been completed, append the new custom view to the components. append: array( 'view' => 'validate-account', ), As shown below: ./custom/modules/Accounts/clients/base/layouts/create/create.php <?php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_Field_Validation_to_the_Record_View/index.html
2def67946c61-5
./custom/modules/Accounts/clients/base/layouts/create/create.php <?php $viewdefs['Accounts']['base']['layout']['create'] = array( 'components' => array( array( 'layout' => array( 'components' => array( array( 'layout' => array( 'components' => array( array( 'view' => 'create', ), array( 'view' => 'validate-account', ), ), 'type' => 'simple', 'name' => 'main-pane', 'span' => 8, ), ), array( 'layout' => array( 'components' => array(), 'type' => 'simple', 'name' => 'side-pane', 'span' => 4, ), ), array( 'layout' => array( 'components' => array( array( 'view' => array ( 'name' => 'dnb-account-create', 'label' => 'DNB Account Create', ), 'width' => 12, ), ), 'type' => 'simple', 'name' => 'dashboard-pane', 'span' => 4, ), ), array( 'layout' => array( 'components' => array( array( 'layout' => 'preview', ), ), 'type' => 'simple', 'name' => 'preview-pane',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_Field_Validation_to_the_Record_View/index.html
2def67946c61-6
'type' => 'simple', 'name' => 'preview-pane', 'span' => 8, ), ), ), 'type' => 'default', 'name' => 'sidebar', 'span' => 12, ), ), ), 'type' => 'simple', 'name' => 'base', 'span' => 12, ); Lastly, depending on the selected module, duplicate its record layout to the modules custom folder to handle editing a record. In the accounts example, we do not have an existing ./modules/Accounts/clients/base/layouts/record/record.php file so we duplicated the core ./clients/base/layouts/record/record.php to ./custom/modules/Accounts/clients/base/layouts/record/record.php. Since we are copying from the ./clients/ core directory, modify: $viewdefs['base']['layout']['record'] = array( ... ); To: $viewdefs['Accounts']['base']['layout']['record'] = array( ... ); After this has been completed, append the new custom view to the components: array( 'view' => 'validate-account', ), The resulting file is shown below: ./custom/modules/Accounts/clients/base/layouts/record/record.php <?php $viewdefs['Accounts']['base']['layout']['record'] = array( 'components' => array( array( 'layout' => array( 'components' => array( array( 'layout' => array( 'components' => array( array( 'view' => 'record', 'primary' => true, ), array( 'view' => 'validate-account',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_Field_Validation_to_the_Record_View/index.html
2def67946c61-7
), array( 'view' => 'validate-account', ), array( 'layout' => 'extra-info', ), array( 'layout' => array( 'name' => 'filterpanel', 'span' => 12, 'last_state' => array( 'id' => 'record-filterpanel', 'defaults' => array( 'toggle-view' => 'subpanels', ), ), 'availableToggles' => array( array( 'name' => 'subpanels', 'icon' => 'icon-table', 'label' => 'LBL_DATA_VIEW', ), array( 'name' => 'list', 'icon' => 'icon-table', 'label' => 'LBL_LISTVIEW', ), array( 'name' => 'activitystream', 'icon' => 'icon-th-list', 'label' => 'LBL_ACTIVITY_STREAM', ), ), 'components' => array( array( 'layout' => 'filter', 'targetEl' => '.filter', 'position' => 'prepend' ), array( 'view' => 'filter-rows', "targetEl" => '.filter-options' ), array( 'view' => 'filter-actions', "targetEl" => '.filter-options' ), array( 'layout' => 'activitystream', 'context' => array( 'module' => 'Activities', ), ), array( 'layout' => 'subpanels', ), ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_Field_Validation_to_the_Record_View/index.html
2def67946c61-8
array( 'layout' => 'subpanels', ), ), ), ), ), 'type' => 'simple', 'name' => 'main-pane', 'span' => 8, ), ), array( 'layout' => array( 'components' => array( array( 'layout' => 'sidebar', ), ), 'type' => 'simple', 'name' => 'side-pane', 'span' => 4, ), ), array( 'layout' => array( 'components' => array( array( 'layout' => array( 'type' => 'dashboard', 'last_state' => array( 'id' => 'last-visit', ) ), 'context' => array( 'forceNew' => true, 'module' => 'Home', ), ), ), 'type' => 'simple', 'name' => 'dashboard-pane', 'span' => 4, ), ), array( 'layout' => array( 'components' => array( array( 'layout' => 'preview', ), ), 'type' => 'simple', 'name' => 'preview-pane', 'span' => 8, ), ), ), 'type' => 'default', 'name' => 'sidebar', 'span' => 12, ), ), ), 'type' => 'simple',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_Field_Validation_to_the_Record_View/index.html
2def67946c61-9
), ), ), 'type' => 'simple', 'name' => 'base', 'span' => 12, ); Once the files are in place, navigate to Admin > Repair > Quick Repair and Rebuild.  Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Adding_Field_Validation_to_the_Record_View/index.html
0ec6164df28b-0
Disabling RLI Alerts on Opportunities Overview How to disable Revenue Line Item (RLI) alerts on Opportunities using a custom JavaScript controller. Overriding the Record View First, we must override the stock opportunities record view. This will handle the RLI alerts when navigating to an existing record. This can be done by creating: ./custom/modules/Opportunities/clients/base/views/record/record.js ({ extendsFrom: 'OpportunitiesRecordView', initialize: function (options) { this._super('initialize', [options]); }, /** * Hide the warning message about missing RLIs * @param string module The module that we are currently on. */ showRLIWarningMessage: function(module) { //here we create an empty override function }, /** * @inheritdoc */ _dispose: function() { this._super('_dispose', []); } }) As you can see, this file extends from 'OpportunitiesRecordView' which points our code to extend the stock ./modules/Opportunities/clients/base/views/record/record.js file. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Disabling_RLI_Alerts_on_Opportunities/index.html
a5e5179524b2-0
Refreshing Subpanels on the RecordView Overview How to refresh specific subpanels on the Record View. Refreshing Subpanels When Working with the Record View, it is sometimes necessary to force the refresh of a subpanel. The following example will demonstrate how to add buttons to force refresh a specific subpanel or all subpanels on the Accounts RecordView. Adding the Button Metadata For our example, we will first create a metadata extension file to append our custom refresh buttons to the Accounts RecordView action menu. ./custom/Extension/modules/Accounts/Ext/clients/base/views/record/refreshButtons.php <?php //module name $module = 'Accounts'; //buttons to append $addButtons = array( array( 'type' => 'divider', ), array ( 'type' => 'rowaction', 'event' => 'button:refresh_specific_subpanel:click', 'name' => 'refresh_specific_subpanel', 'label' => 'LBL_REFRESH_SPECIFIC_SUBPANEL', 'acl_action' => 'view', ), array ( 'type' => 'rowaction', 'event' => 'button:refresh_all_subpanels:click', 'name' => 'refresh_all_subpanels', 'label' => 'LBL_REFRESH_ALL_SUBPANELS', 'acl_action' => 'view', ) ); //if the buttons are missing in our base modules metadata, include core buttons if (!isset($viewdefs[$module]['base']['view']['record']['buttons'])) { require('clients/base/views/record/record.php'); $viewdefs[$module]['base']['view']['record']['buttons'] = $viewdefs['base']['view']['record']['buttons']; unset($viewdefs['base']); }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Refreshing_Subpanels_on_the_Record_View/index.html
a5e5179524b2-1
unset($viewdefs['base']); } foreach($viewdefs[$module]['base']['view']['record']['buttons'] as $outerKey => $outerButton) { if ( isset($outerButton['type']) && $outerButton['type'] == 'actiondropdown' && isset($outerButton['name']) && $outerButton['name'] == 'main_dropdown' && isset($outerButton['buttons']) ) { /* //removing buttons by name foreach($viewdefs[$module]['base']['view']['record']['buttons'][$outerKey]['buttons'] as $innerKey => $innerButton) { if ( isset($innerButton['name']) && $innerButton['name'] == 'button_name' ) { unset($viewdefs[$module]['base']['view']['record']['buttons'][$outerKey]['buttons'][$innerKey]); } } */ //appending buttons foreach ($addButtons as $addButton) { $viewdefs[$module]['base']['view']['record']['buttons'][$outerKey]['buttons'][]=$addButton; } } } Next, we will create our language labels for the buttons. ./custom/Extension/modules/Accounts/Ext/Language/en_us.refreshButtons.php <?php $mod_strings['LBL_REFRESH_SPECIFIC_SUBPANEL'] = 'Refresh Specific Subpanel'; $mod_strings['LBL_REFRESH_ALL_SUBPANELS'] = 'Refresh All Subpanels'; Our next step is to extend the Accounts controller file. This is where we will add our code to refresh the subpanels when the buttons are clicked. ./custom/modules/Accounts/clients/base/views/record/record.js ({
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Refreshing_Subpanels_on_the_Record_View/index.html
a5e5179524b2-2
./custom/modules/Accounts/clients/base/views/record/record.js ({ extendsFrom: 'RecordView', initialize: function (options) { this._super('initialize', [options]); //add listeners for custom buttons this.context.on('button:refresh_specific_subpanel:click', this.refresh_specific_subpanel, this); this.context.on('button:refresh_all_subpanels:click', this.refresh_all_subpanels, this); }, /** * Refreshes a specific subpanel given a link */ refresh_specific_subpanel: function() { var linkName = 'contacts'; var subpanelCollection = this.model.getRelatedCollection(linkName); subpanelCollection.fetch({relate: true}); }, /** * Refreshes all subpanels */ refresh_all_subpanels: function() { _.each(this.model._relatedCollections, function(collection){ collection.fetch({relate: true}); }); } }) Note: To refresh a specific subpanel, you will need to pass the linkname of the relationship to the this.model.getRelatedCollection() method. Finally, we will then need to navigate to Admin > Repair > Quick Repair and Rebuild. This will rebuild our extensions and make the refresh buttons available on our RecordView. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Refreshing_Subpanels_on_the_Record_View/index.html
ce16bf15eefd-0
This page applies to the legacy "BWC" calendar offering. Sugar has released a Sidecar-based calendar in version 11.2.0; this content does not apply to the Sidecar calendar. Modifying Calendar Item Colors Overview Each calendar event type (Meetings, Calls, and Tasks) has its own distinct color scheme. This article will review how to modify these colors, as well as demonstrate how to set the event color based on the event status. The color scheme for each calendar activity type is defined in the stock file ./modules/Calendar/CalendarDisplay.php in the $activity_colors array as shown below: public $activity_colors = array( 'Meetings' => array( 'border' => '#1C5FBD', 'body' => '#D2E5FC', ), 'Calls' => array( 'border' => '#DE4040', 'body' => '#FCDCDC', ), 'Tasks' => array( 'border' => '#015900', 'body' => '#B1F5AE', ), ); This file can not be overridden or extended in an upgrade-safe way, but this array can still be overridden later in the rendering process allowing for an upgrade safe customization. Modifying the Calendar Activity Colors The CalendarDisplay class passes the $activity_colors array to javascript by way of the ./modules/Calendar/tpls/main.tpl Smarty template. In this template file, you will see the following code where the CAL.activity_colors object is setup: CAL.activity_colors = []; {foreach name=colors from=$activity_colors key=module item=v} CAL.activity_colors['{$module}'] = []; CAL.activity_colors['{$module}']['border'] = '{$v.border}';
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Modifying_Calendar_Item_Colors/index.html
ce16bf15eefd-1
CAL.activity_colors['{$module}']['border'] = '{$v.border}'; CAL.activity_colors['{$module}']['body'] = '{$v.body}' {/foreach} This is where we can update the $activity_colors array in an upgrade safe manner. To do this, copy the template file from./modules/Calendar/tpls/main.tpl to ./custom/modules/Calendar/tpls/main.tpl. If we wanted to change Meetings to have a purple color scheme, we might choose: border: #580059body : #F2AEF5 To implement this, we'll update the activity colors array in the custom template file as follows: ./custom/modules/Calendar/tpls/main.tpl CAL.activity_colors = []; {foreach name=colors from=$activity_colors key=module item=v} CAL.activity_colors['{$module}'] = []; CAL.activity_colors['{$module}']['border'] = '{$v.border}'; CAL.activity_colors['{$module}']['body'] = '{$v.body}' {/foreach} {literal} CAL.activity_colors["Meetings"] = { "border": "#580059", "body": "#F2AEF5" }; {/literal} In the above code, the activity_colors entry for "Meetings" has specifically been altered to set the custom colors just for Meetings, leaving the other activity types as they were. Alternatively, the entire activity_colors array could be updated, replacing the original coming from CalendarDisplay. For example: ./custom/modules/Calendar/tpls/main.tpl CAL.activity_colors = []; {foreach name=colors from=$activity_colors key=module item=v} CAL.activity_colors['{$module}'] = []; CAL.activity_colors['{$module}']['border'] = '{$v.border}';
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Modifying_Calendar_Item_Colors/index.html
ce16bf15eefd-2
CAL.activity_colors['{$module}']['border'] = '{$v.border}'; CAL.activity_colors['{$module}']['body'] = '{$v.body}' {/foreach} {literal} CAL.activity_colors = { "Meetings": { "border": "#580059", "body": "#F2AEF5" }, "Calls": { "border": "#DE4040", "body": "#FCDCDC" }, "Tasks": { "border": "#015900", "body": "#B1F5AE" } }; {/literal} While Calls and Tasks have not been modified from their original colors, having the entire array defined here may make it easier to make further color customizations later on, since the modified activity_colors will be completely defined in the custom template file. After making the above changes, run a Quick Repair and Rebuild and reload the Calendar module in your browser to see the changes take effect. Customizing colors based on event status If you wanted to go a step further, you might want to customize the colors based on the status of the activity. For example, perhaps for Meetings, the color should reflect if the Meeting status is Scheduled, Held, or Canceled. To achieve this, we will need to customize the javascript that actually renders the activities onto the calendar view, so we will copy ./modules/Calendar/Cal.js to ./custom/modules/Calendar/Cal.js. Additionally, in order for our custom template to load the custom Cal.js, it will need to be updated to point to the custom Cal.js by changing the line: {sugar_getscript file="modules/Calendar/Cal.js"} to
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Modifying_Calendar_Item_Colors/index.html
ce16bf15eefd-3
{sugar_getscript file="modules/Calendar/Cal.js"} to {sugar_getscript file="custom/modules/Calendar/Cal.js"} The activity colors from the CAL.activity_colors object get applied in the Cal.js script at: el.style.backgroundColor = CAL.activity_colors[item.module_name]['body']; el.style.borderColor = CAL.activity_colors[item.module_name]['border']; The activity type (Meetings, Calls, Tasks) comes from item.module_name, as shown above. The activity's status can be found in the item.status variable. Using these, we can modify the color-setting logic to apply a status-specific color scheme to the Meeting items in the calendar, for example: if (item.module_name =="Meetings") { el.style.backgroundColor = CAL.activity_colors[item.module_name][item.status]['body']; el.style.borderColor = CAL.activity_colors[item.module_name][item.status]['border']; } else { el.style.backgroundColor = CAL.activity_colors[item.module_name]['body']; el.style.borderColor = CAL.activity_colors[item.module_name]['border']; } This assumes that the 'Meetings' part of CAL.activity_colors has status-specific colors set. Therefore we will need to update our custom template file so that this is the case: ./custom/modules/Calendar/tpls/main.tpl {literal} CAL.activity_colors = { "Meetings": { "Planned": { "border": "#FF6666", "body": "#FF6666" }, "Held": { "border": "#FF9999", "body": "#FF9999" }, "Not Held": { "border": "#6C8CD5", "body": "#6C8CD5" } }, "Calls": {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Modifying_Calendar_Item_Colors/index.html
ce16bf15eefd-4
} }, "Calls": { "border": "#DE4040", "body": "#FCDCDC" }, "Tasks": { "border": "#015900", "body": "#B1F5AE" }, "Planned": { "border": "#ff6666", "body": "#ff6666" }, "Held": { "border": "#FF9999", "body": "#FF9999" }, "Not Held": { "border": "#6C8CD5", "body": "#6C8CD5" } }; {/literal} After making the above changes, run Rebuild JS Grouping Files followed by a Quick Repair and Rebuild, then reload the Calendar module in your browser to see the changes take effect. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Modifying_Calendar_Item_Colors/index.html
99db50619d9a-0
Prepopulating the Compose Email View Overview When composing an email in Sugar, it may be useful to modify the compose view to better suit your common business practices. In this article, we will use JavaScript to create a code-level customization which causes the To, CC, and Subject fields of the email to prepopulate with data from a related Opportunity. Steps to Complete Create a Custom Compose Email View To modify the default compose email functionality, we will need to create our own compose-email view that extends from the base compose-email view. To accomplish this, we will need to create the following file: ./custom/modules/Emails/clients/base/views/compose-email/compose-email.js ({ extendsFrom: 'EmailsComposeEmailView', initialize: function(options){ this._super('initialize',[options]); this.configureDefaults(); }, /** * Configure the default data */ configureDefaults: function(){ var model = this.context.parent.get('model'); var module = this.context.parent.get('module'); if (module == 'Opportunities'){ var contacts; var oppName = model.get('name'); if (this.model.get('to_collection').length === 0) { var email = this.model; //Get the related contacts to the Opportunity contacts = model.getRelatedCollection('contacts'); contacts.fetch({ relate: true, success: function (data) { var ccRecords = [], toRecords = []; data.forEach(function (record) { var parentName = app.utils.getRecordName(record); if (record.attributes.opportunity_role == 'Primary Decision Maker') { //Primary decisions makers are added to the TO Recipients toRecords.push(app.data.createBean('EmailParticipants', {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Prepopulating_the_Compose_Email_View/index.html
99db50619d9a-1
toRecords.push(app.data.createBean('EmailParticipants', { _link: 'to', parent: _.extend({type: record.module}, record.attributes), parent_type: record.module, parent_id: record.get('id'), parent_name: parentName })); } else { //All other contacts are added to the CC Recipients ccRecords.push(app.data.createBean('EmailParticipants', { _link: 'cc', parent: _.extend({type: record.module}, record.attributes), parent_type: record.module, parent_id: record.get('id'), parent_name: parentName })); } }); email.get('to_collection').add(toRecords); email.get('cc_collection').add(ccRecords); }, fields: ['id', 'full_name', 'email', 'opportunity_role'] }); } //Default the Subject of Email to the Opportunity Name email.set('name',oppName); } } }) Some key things to note about this customization: The custom view should extend from EmailsComposeEmailView When adding recipients to an Email Bean Model, you should create an EmailParticipants Bean Model and specify the _link property that will be used. This view will be used when clicking on the "Create" button in the Emails subpanel, or when clicking on Email Address on a record when the user is configured to use the Sugar Email Client Once you have added the custom code, execute a Quick Repair and rebuild via Admin > Repair > Quick Repair and Rebuild, and your changes should now be reflected in your instance. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Prepopulating_the_Compose_Email_View/index.html
a22d56fcef53-0
Customizing the Start Speed of List View Search Overview When searching a Sidecar module's list view, Sugar® begins returning results automatically once a predefined number of milliseconds have passed. This article covers how to customize the start speed of the list view search for Sidecar modules in Sugar. Prerequisites This change requires code-level customizations, and you will need direct access to the server in order to make the necessary changes in the file system. If you already have a relationship with a Sugar partner, you can work with them to make this customization. If not, please refer to the Partner Page to find a reselling partner to help with your development needs.  Note: If your instance is hosted in Sugar's cloud environment, you can create a package that can be installed within Admin > Module Loader. For more information, please refer to the Creating an Installable Package That Copies Files article. Note: Sugar Sell Essentials customers do not have the ability to upload custom file packages to Sugar using Module Loader. Use Case By default, the list view search process in Sugar begins to run 400 milliseconds after a user stops typing or pasting values into one of the search fields. For some users or situations, the system-defined start speed for list view search may be considered too fast. We will walk through increasing the length of time it takes before the search starts to run, using 750 milliseconds as an example. Steps to Complete The function that controls the list view search speed in Sugar can be found in the following file: ./clients/base/views/filter-quicksearch/filter-quicksearch.js In order to customize this function, please use the following steps to create an extension in the ./custom/ directory: Navigate to the ./custom/ directory in the Sugar file system and create the following directory structure if it does not already exist: ./clients/base/views/filter-quicksearch/.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Customizing_the_Start_Speed_of_List_View_Search/index.html
a22d56fcef53-1
In a text editor application, create a new file. Copy the code provided below into this new file:({ extendsFrom: 'FilterQuicksearchView', /** * @override * @param {Object} opts */ initialize: function(opts) { this._super('initialize', [opts]); }, /** * Fire quick search * @param {Event} e */ throttledSearch: _.debounce(function(e) { var newSearch = this.$el.val(); if(this.currentSearch !== newSearch) { this.currentSearch = newSearch; this.layout.trigger('filter:apply', newSearch); } }, 750), }) For our example, the value of "750" at the end of the code represents the new start speed of list view search. Feel free to replace it with your desired value in milliseconds. Save the new file as./custom/clients/base/views/filter-quicksearch/filter-quicksearch.js. Update the Ownership and Permissions of the directories and file that were created. For more information on Linux based stacks, please refer to the article Required File System Permissions on Linux. For more information on Windows-based stacks, please refer to the article Required File System Permissions on Windows With IIS. Finally, log into Sugar and navigate to Admin > Repair then perform a "Quick Repair and Rebuild". After completing the steps in this article, Sugar will wait 750 milliseconds before returning search results once the user has stopped entering search criteria. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Customizing_the_Start_Speed_of_List_View_Search/index.html
dea755700303-0
Disabling Tooltips Overview This article will demonstrate how to disable the tooltips in Sugar. Steps to Complete Creating a Custom JavaScript File First, we will need to create a custom JavaScript file. This file can technically exist anywhere within the root of your Sugar instance. custom/JavaScript/disable_tooltips.js (function(app){ app.events.on('app:init', function(){ // Clear existing ones app.tooltip.clear(); // Disable all app.tooltip._disable(); }); })(SUGAR.App); Appending to JSGroupings Second, we need to add our disable_tooltips.js file to sugar_grp7.min.js in our JSGroupings. custom/Extension/application/Ext/JSGroupings/disable_tooltips.php <?php foreach ($js_groupings as $key => $groupings) { foreach ($groupings as $file => $target) { if ($target == 'include/javascript/sugar_grp7.min.js') { $js_groupings[$key]['custom/JavaScript/disable_tooltips.js'] = 'include/javascript/sugar_grp7.min.js'; } break; } } Note: More information about JSGroupings can be found here. Quick Repair and Rebuild After creating the ./custom/JavaScript/disable_tooltips.js and ./custom/Extension/application/Ext/JSGroupings/disable_tooltips.php files, navigate to Admin > Repairs and perform a "Quick Repair and Rebuild". This will rebuild the cached files to fully implement the changes.  Once "Quick Repair and Rebuild" finishes, the tooltips will be disabled through Sugar. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Disabling_Tooltips/index.html
e39713af9e2d-0
Logic Hooks These pages demonstrate some common examples of working with logic hooks in Sugar. TopicsComparing Bean Properties Between Logic HooksHow to compare the properties of a bean between the before_save and after_save logic hooksPreventing Infinite Loops with Logic HooksHow to add a check to a logic hook to eliminate perpetual looping Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Logic_Hooks/index.html
ade508676418-0
Preventing Infinite Loops with Logic Hooks Overview Infinite loops often happen when a logic hook calls save on a bean in a scenario that triggers the same hook again. This example shows how to add a check to a logic hook to eliminate perpetual looping. Saving in an After Save Hook Infinite loops can sometimes happen when you have a need to update a record after it has been run through the workflow process in the after_save hook. Here is an example of a looping hook: ./custom/modules/Accounts/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_save'] = Array(); $hook_array['after_save'][] = Array( 1, 'Update Account Record', 'custom/modules/Accounts/Accounts_Hook.php', 'Accounts_Hook', 'update_self' ); ./custom/modules/Accounts/Accounts_Hook.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class Accounts_Hook { function update_self($bean, $event, $arguments) { //generic condition if ($bean->account_type == 'Analyst') { //update $bean->industry = 'Banking'; $bean->save(); } } }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Logic_Hooks/Preventing_Infinite_Loops_with_Logic_Hooks/index.html
ade508676418-1
$bean->save(); } } } In the example above, there is a condition that, when met, will trigger the update of a field on the record. This will cause an infinite loop because calling the save() method will trigger once during the before_save hook and then again during the after_save hook. The solution to this problem is to add a new property on the bean to ignore any unneeded saves. For this example, we will name the property "ignore_update_c" and add a check to the logic hook to eliminate the perpetual loop. An example of this is shown below: ./custom/modules/Accounts/Accounts_Hook.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class Accounts_Hook { function update_self($bean, $event, $arguments) { //loop prevention check if (!isset($bean->ignore_update_c) || $bean->ignore_update_c === false) { //generic condition if ($bean->account_type == 'Analyst') { //update $bean->ignore_update_c = true; $bean->industry = 'Banking'; $bean->save(); } } } } Related Record Save Loops Sometimes logic hooks on two separate but related modules can cause an infinite loop. The problem arises when the two modules have logic hooks that update one another. This is often done when wanting to keep a field in sync between two modules. The example below will demonstrate this behavior on the accounts:contacts relationship: ./custom/modules/Accounts/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_save'] = Array();
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Logic_Hooks/Preventing_Infinite_Loops_with_Logic_Hooks/index.html
ade508676418-2
$hook_array = Array(); $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array( 1, 'Handling associated Contacts records', 'custom/modules/Accounts/Accounts_Hook.php', 'Accounts_Hook', 'update_contacts' ); ./custom/modules/Accounts/Accounts_Hook.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class Accounts_Hook { function update_contacts($bean, $event, $arguments) { //if relationship is loaded if ($bean->load_relationship('contacts')) { //fetch related beans $relatedContacts = $bean->contacts->getBeans(); foreach ($relatedContacts as $relatedContact) { //perform any other contact logic $relatedContact->save(); } } } } The above example will loop through all contacts related to the account and save them. At this point, the save will then trigger our contacts logic hook shown below: ./custom/modules/Contacts/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array( 1, 'Handling associated Accounts records', 'custom/modules/Contacts/Contacts_Hook.php', 'Contacts_Hook', 'update_account' ); ./custom/modules/Contacts/Contacts_Hook.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class Contacts_Hook { function update_account($bean, $event, $arguments) {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Logic_Hooks/Preventing_Infinite_Loops_with_Logic_Hooks/index.html
ade508676418-3
{ function update_account($bean, $event, $arguments) { //if relationship is loaded if ($bean->load_relationship('accounts')) { //fetch related beans $relatedAccounts = $bean->accounts->getBeans(); $parentAccount = false; if (!empty($relatedAccounts)) { //order the results reset($relatedAccounts); //first record in the list is the parent $parentAccount = current($relatedAccounts); } if ($parentAccount !== false && is_object($parentAccount)) { //perform any other account logic $parentAccount->save(); } } } } These two logic hooks will continuously trigger one another in this scenario until you run into a max_execution or memory_limit error. The solution to this problem is to add a new property on the bean to ignore any unneeded saves. In our example, we will name this property "ignore_update_c" and add a check to our logic hook to eliminate the perpetual loop. The following code snippets are copies of the two classes with the ignore_update_c property added. ./custom/modules/Accounts/Accounts_Hook.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class Accounts_Hook { function update_contacts($bean, $event, $arguments) { //if relationship is loaded if ($bean->load_relationship('contacts')) { //fetch related beans $relatedContacts = $bean->contacts->getBeans(); foreach ($relatedContacts as $relatedContact) { //check if the bean's ignore_update_c attribute is not set
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Logic_Hooks/Preventing_Infinite_Loops_with_Logic_Hooks/index.html
ade508676418-4
{ //check if the bean's ignore_update_c attribute is not set if (!isset($bean->ignore_update_c) || $bean->ignore_update_c === false) { //set the ignore update attribute $relatedContact->ignore_update_c = true; //perform any other contact logic $relatedContact->save(); } } } } } ./custom/modules/Contacts/Contacts_Hook.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class Contacts_Hook { function update_account($bean, $event, $arguments) { //if relationship is loaded if ($bean->load_relationship('accounts')) { //fetch related beans $relatedAccounts = $bean->accounts->getBeans(); $parentAccount = false; if (!empty($relatedAccounts)) { //order the results reset($relatedAccounts); //first record in the list is the parent $parentAccount = current($relatedAccounts); } if ($parentAccount !== false && is_object($parentAccount)) { //check if the bean's ignore_update_c element is set if (!isset($bean->ignore_update_c) || $bean->ignore_update_c === false) { //set the ignore update attribute $parentAccount->ignore_update_c = true; //perform any other account logic $parentAccount->save(); } } } } } Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Logic_Hooks/Preventing_Infinite_Loops_with_Logic_Hooks/index.html
d5636bc79d06-0
Comparing Bean Properties Between Logic Hooks Overview How to compare the properties of a bean between the before_save and after_save logic hooks Storing and Comparing Values When working with a bean in the after_save logic hook, you may notice that the after_save fetched rows no longer match the before_save fetched rows. If your after_save logic needs to be able to compare values that were in the before_save, you can use the following example to help you store and use the values. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array( 1, 'Store values', 'custom/modules/<module>/My_Logic_Hooks.php', 'My_Logic_Hooks', 'before_save_method' ); $hook_array['after_save'] = Array(); $hook_array['after_save'][] = Array( 1, 'Retrieve and compare values', 'custom/modules/<module>/My_Logic_Hooks.php', 'My_Logic_Hooks', 'after_save_method' ); ?> ./custom/modules/<module>/My_Logic_Hooks.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class My_Logic_Hooks { function before_save_method($bean, $event, $arguments) { //store as a new bean property $bean->stored_fetched_row_c = $bean->fetched_row; } function after_save_method($bean, $event, $arguments) { //check if a fields value has changed if (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Logic_Hooks/Comparing_Bean_Properties_Between_Logic_Hooks/index.html
d5636bc79d06-1
{ //check if a fields value has changed if ( isset($bean->stored_fetched_row_c) && $bean->stored_fetched_row_c['field'] != $bean->field ) { //execute logic } } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Logic_Hooks/Comparing_Bean_Properties_Between_Logic_Hooks/index.html
a393bfdbc0df-0
Moving Footer content to Sidebar Nav Overview This example explains how to add additional buttons to a new section in the sidebar nav layout. You may have previously customized a button that was added to the footer layout, which can be repurposed here and added to the sidebar-nav layout. We will create a custom view and append the view component to the sidebar-nav layout metadata. The additional button will merely show an alert and a flyout menu with a link to the Accounts module but can be expanded to do much more. Steps To Complete This tutorial requires the following steps, which are explained in the sections below: Extend the language files to include the new labels Creating the Custom View Appending the View to Layout Metadata Adding a Secondary Action Extending the Language files to Include New Labels We'll want to add a couple of new labels for our new sidebar-nav-item. To do this, create the following file: ./custom/Extension/application/Ext/Language/en_us.greetingNavItem.php <?php // Create the "Hello" label $app_strings['LBL_HELLO_C'] = 'Hello!'; Creating the Custom View with a Primary Action To add a new sidebar-nav-item, you will first need to create the custom view that extends sidebar-nav-item. To create the custom view create a folder in ./custom/clients/base/views with the name of your view, such as ./custom/clients/base/views/greeting-nav-item/. Once your folder is in place, you can create the two primary files that make up your view. By default, we can use the out-of-the-box template for our view. greeting-nav-item.js - Contains the JavaScript controller logic greeting-nav-item.php - Contains the metadata your view might use. For this example, we simply use the metadata to define whether the greeting will auto-close or not. ./custom/clients/base/views/greeting-nav-item/greeting-nav-item.js
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Moving_Footer_content_to_Sidebar_Nav/index.html
a393bfdbc0df-1
./custom/clients/base/views/greeting-nav-item/greeting-nav-item.js ({ extendsFrom: 'SidebarNavItemView', primaryActionOnClick: function() { app.alert.show('greeting-alert', { level: 'info', messages: 'Hello '+ app.user.get('full_name') + '!', autoClose: this.meta.autoClose || false }); }, }) ./custom/clients/base/views/greeting-nav-item/greeting-nav-item.php: <?php $viewdefs['base']['view']['greeting-nav-item'] = array( 'autoClose' => true ); Appending the View to Layout Metadata Once the view is created, you simply need to add the view to the sidebar-nav Layout metadata. The sidebar-nav Layout is located in ./clients/base/layouts/sidebar-nav/, so appending the view to this layout can be done via the Extension Framework. Create a file  ./custom/Extension/application/Ext/clients/base/layouts/sidebar-nav/ and the Extension Framework will append the metadata to the sidebar-nav Layout. ./custom/Extension/application/Ext/clients/base/layouts/sidebar-nav/greeting-nav-item.php <?php $viewdefs['base']['layout']['sidebar-nav']['components'][] = [ 'view' => [ 'name' => 'greeting-nav-item', 'type' => 'greeting-nav-item', 'icon' => 'sicon-bell-lg', 'label' => 'LBL_HELLO_C', 'template' => 'sidebar-nav-item', ], ]; Once all the files are in place, you can run a Quick Repair and Rebuild and a new group  sidebar-nav-item at the bottom of the sidebar-nav bar layout. Â
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Moving_Footer_content_to_Sidebar_Nav/index.html
a393bfdbc0df-2
  Note: You may need to refresh the page to see the profile menu items removed. Adding a Secondary Action With the introduction of the sidebar-nav-item component, we're now introducing Secondary Actions. These appear by way of a kebab menu when hovering on the sidebar-nav-item container to which they are added. It can be configured similarly to a Primary Action. In this example, we'll add a secondary action to our greeting-nav-item view. It will trigger a flyout menu that has a link to the Accounts module. First, let's add a new label to the language file we created earlier for our flyout menu header: <?php // Create the "Greetings" header $app_strings['LBL_GREETINGS_C'] = 'Greetings';   Next, we can define the components that will be used in the flyout menus via metadata in greeting-nav-item.php. The new metadata looks like this: ./custom/Extension/application/Ext/clients/base/layouts/sidebar-nav/greeting-nav-item.php <?php $viewdefs['base']['layout']['sidebar-nav']['components'][] = [ 'view' => [ 'name' => 'greeting-nav-item', 'type' => 'greeting-nav-item', 'icon' => 'sicon-bell-lg', 'label' => 'LBL_HELLO_C', 'secondary_action' => true, 'template' => 'sidebar-nav-item', 'flyoutComponents' => [ [ 'view' => 'sidebar-nav-flyout-header', 'title' => 'LBL_GREETINGS_C', ], [ 'view' => [ 'type' => 'sidebar-nav-flyout-actions', 'actions' => [ [
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Moving_Footer_content_to_Sidebar_Nav/index.html
a393bfdbc0df-3
'actions' => [ [ 'route' => '#Accounts', 'label' => 'LBL_ACCOUNTS', 'icon' => 'sicon-account-lg', ], ], ], ], ], ], ];   Once these changes are added, you can run a Quick Repair and Rebuild and sidebar-nav-item will be updated with a Secondary Action.   Note: You may need to refresh the page to see the profile menu items removed.   Customizing the sidebar-nav-item Template By default, our new sidebar-nav-item is using the base Handlebars template. If you'd like to customize the template, create the following Handlebar Template file greeting-nav-item.hbs. The following snippet is the template for the base view for reference.  ./custom/clients/base/views/greeting-nav-item/greeting-nav-item.hbs {{#if appIsSynced}} <button class="sidebar-nav-item-btn w-full bg-transparent absolute p-0 text-base text-initial" rel="tooltip" data-placement="{{tooltipPlacement}}" title="{{str label}}" > <span class="collapsed block ml-0 px-5.5 py-2" rel="tooltip" data-placement="{{tooltipPlacement}}" title="{{str label module}}"> <i class="{{buildIcon icon}} text-white"></i> </span> <span class="expanded ellipsis_inline ml-0 px-5.5 py-2 text-white" rel="tooltip" data-placement="{{tooltipPlacement}}" title="{{str label module}}"> <i class="{{buildIcon icon}} text-white"></i> <span class="text-sm pl-4.5">{{str label}}</span>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Moving_Footer_content_to_Sidebar_Nav/index.html
a393bfdbc0df-4
<span class="text-sm pl-4.5">{{str label}}</span> </span> </button> {{#if secondaryAction}} <button class="sidebar-nav-item-kebab bg-transparent absolute p-0 h-full"> <i class="{{buildIcon 'sicon-kebab'}} text-white"></i> </button> {{/if}} {{/if}} Next, in ./custom/Extension/application/Ext/clients/base/layouts/sidebar-nav/greeting-nav-item.php remove the 'template' => 'sidebar-nav-item' metadata entry.  Note: Sidebar components must be expanded/collapsed state aware now, therefore you must make sure to provide collapsed (simple icon) and expanded (icon + text) class elements in your buttons. Changing position of sidebar-nav-item If you need to change the position of the sidebar-nav-item in the sidebar-nav layout, it is recommended that the layout be redefined using custom metadata. For example, if you wanted to move the group we created above, we could define the custom metadata as such: ./custom/clients/base/layouts/sidebar-nav/sidebar-nav.php <?php /* * Your installation or use of this SugarCRM file is subject to the applicable * terms available at * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/. * If you do not agree to all of the applicable terms or do not have the * authority to bind the entity as an authorized representative, then do not * install or use this SugarCRM file. * * Copyright (C) SugarCRM Inc. All rights reserved. */ $viewdefs['base']['layout']['sidebar-nav'] = [ 'components' => [
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Moving_Footer_content_to_Sidebar_Nav/index.html
a393bfdbc0df-5
$viewdefs['base']['layout']['sidebar-nav'] = [ 'components' => [ [ 'layout' => '...', ], [ 'layout' => [ 'type' => 'sidebar-nav-item-group-modules', 'css_class' => 'flex-grow flex-shrink', ], ], [ 'layout' => [ 'type' => 'sidebar-nav-item-group', 'name' => 'sidebar-nav-item-group-bottom', 'css_class' => 'flex-grow-0 flex-shrink-0', 'components' => [ [ 'view' => [ 'name' => 'footer-greet-button', 'type' => 'footer-greet-button', 'route' => '#Accounts', 'icon' => 'sicon-bell-lg', 'label' => 'Hello!', 'flyoutComponents' => [ [ 'view' => 'sidebar-nav-flyout-header', 'title' => 'Greetings', ], [ 'view' => [ 'type' => 'sidebar-nav-flyout-actions', 'actions' => [ [ 'route' => '#Accounts', 'label' => 'LBL_ACCOUNTS', 'icon' => 'sicon-account-lg', ], ], ], ], ], ], ], ], ], ], [ 'layout' => [ 'type' => 'sidebar-nav-item-group', 'name' => 'sidebar-nav-item-group-bottom', 'css_class' => 'flex-grow-0 flex-shrink-0', 'components' => [ ... ], ],
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Moving_Footer_content_to_Sidebar_Nav/index.html
a393bfdbc0df-6
'components' => [ ... ], ], ], ], ]; Note: Although this is a best practice for customizing base metadata, these base layouts are subject to change and may be changed in the future. Maintenance of these customizations belongs to the owner of the instance.   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Moving_Footer_content_to_Sidebar_Nav/index.html
f6aafbb6b3f6-0
Module Loadable Packages Examples working with the module loadable packages. TopicsCreating an Installable Package for a Logic HookThese examples will demonstrate how to create module loadable packages for logic hooks based on different scenarios.Creating an Installable Package That Copies FilesThis is an overview of how to create a module loadable package that will copy files into your instance of Sugar. This is most helpful when your instance is hosted in Sugar's cloud environment or by a third party. For more details on the $manifest or $installdef options, you can visit the Introduction to the Manifest. This example package can be downloaded here.Creating an Installable Package that Creates New FieldsThis is an overview of how to create a Module Loader package that will install custom fields to a module. This example will install a set of fields to the accounts module. The full package is downloadable here for your reference. For more details on the $manifest or $installdef options, you can visit the Introduction to the Manifest File.Removing Files with an Installable PackageThis is an overview of how to create a module loadable package that will remove files from the custom directory that may have been left over from a previous package installation or legacy versions of your code customization. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Module_Loadable_Packages/index.html
eb2fe0596d07-0
Removing Files with an Installable Package Overview This is an overview of how to create a module loadable package that will remove files from the custom directory that may have been left over from a previous package installation or legacy versions of your code customization.  Note: For SugarCloud customers, this method will not work because removing files is prohibited by Package Scanner. To have files removed, you can submit a case to Sugar Support with a list of files to be removed or request a package approval and provide your module loadable package. This example will install a custom file and use a pre-execute script to remove files from a previously installed customization. Typically, uninstalling a package would remove the files of the customization, however, in some scenarios, it is desired to install a new package on top of a previous version, and removing files with the new package might be necessary. The full package for this example is downloadable here for your reference. For more details on the $manifest or $installdef options, you can visit the Introduction to the Manifest documentation.  Manifest Example <basepath>/manifest.php <?php $manifest = array( 'acceptable_sugar_flavors' => array( 'PRO', 'ENT', 'ULT' ), 'acceptable_sugar_versions' => array( 'exact_matches' => array(), 'regex_matches' => array( '13.0.* '), ), 'author' => 'SugarCRM', 'description' => 'Installs a custom class file', 'icon' => '', 'is_uninstallable' => true, 'name' => 'Example Removing File Installer', 'published_date' => '2018-12-06 00:00:00',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Module_Loadable_Packages/Removing_Files_with_an_Installable_Package/index.html
eb2fe0596d07-1
'type' => 'module', 'version' => '1.2.0' ); $installdefs = array( 'id' => 'package_1341607504', 'copy' => array( array( 'from' => '<basepath>/Files/custom/src/CustomClass.php', 'to' => 'custom/src/CustomClass.php', ), ), 'pre_execute' => array( '<basepath>/removeLegacyFiles.php', ), 'remove_files' => array( 'custom/include/CustomClass.php' ) ); <basepath>/removeLegacyFiles.php  <?php if (isset($this->installdefs['remove_files'])) { foreach($this->installdefs['remove_files'] as $relpath){ if (SugarAutoloader::fileExists($relpath)) { SugarAutoloader::unlink($relpath); } } } The full package is downloadable here for your reference. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Module_Loadable_Packages/Removing_Files_with_an_Installable_Package/index.html
bd0f1f84f106-0
Creating an Installable Package That Copies Files Overview This is an overview of how to create a module loadable package that will copy files into your instance of Sugar. This is most helpful when your instance is hosted in Sugar's cloud environment or by a third party. For more details on the $manifest or $installdef options, you can visit the Introduction to the Manifest. This example package can be downloaded here. Manifest Example <?php $manifest = array( 'acceptable_sugar_flavors' => array('PRO','ENT','ULT'), 'acceptable_sugar_versions' => array( 'exact_matches' => array(), 'regex_matches' => array('(.*?)\\.(.*?)\\.(.*?)$'), ), 'author' => 'SugarCRM', 'description' => 'Copies my files to custom/src/', 'icon' => '', 'is_uninstallable' => true, 'name' => 'Example File Installer', 'published_date' => '2018-06-29 00:00:00', 'type' => 'module', 'version' => '1.0.0', ); $installdefs = array( 'id' => 'package_1530305622', 'copy' => array( 0 => array( 'from' => '<basepath>/Files/custom/src/MyLibrary/MyCustomClass.php', 'to' => 'custom/src/MyLibrary/MyCustomClass.php', ), ), ); Copied File Example
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Module_Loadable_Packages/Creating_an_Installable_Package_That_Copies_Files/index.html