id
stringlengths
14
16
text
stringlengths
33
5.27k
source
stringlengths
105
270
909b56d792ff-21
->getBody() ->getContents(); // POST echo (new ExternalResourceClient()) ->post( 'http://httpbin.org/post', ['fieldName' => 'value', 'fieldName2' => 'another value'] ) ->getBody() ->getContents(); Upload a file The following code snippet provides you with a code example using ExternalResourceClient to upload files from Sugar. // Uploading files from `upload` directory // File data will be accessible on the target server as $_FILES['file_field_name'] echo 'File upload', PHP_EOL, PHP_EOL; $file = new UploadFile('file_field_name'); // relative to `upload` directory $filename = 'f68/2cad6f68-e016-11ec-9c9c-0242ac140007';
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html
909b56d792ff-22
$file->temp_file_location = $file->get_upload_path($filename); // try + catch is omitted for brevity echo (new ExternalResourceClient())->upload( $file, 'https://httpbin.org/post', 'POST', ['foo' => 'bar'], // Optional, additional form data ['custom-header-name' => 'custom-header-value'] // Optional, additional headers )->getBody()->getContents(); Last modified: 2023-04-25 18:53:05
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/ExternalResourceClient/index.html
76ad35f93c68-0
Best Practices Overview Best practices when integrating and migrating Sugar. Latency When Posting Data To Sugar When integrating with Sugar, it is best to avoid long-running web requests. While performance-draining requests are not always obvious, once an issue has been identified, it is best to move the processing to the backend. By default, we expect a request to an endpoint such as POST /Accounts to be straightforward, however, adding Workflows, Logic Hooks, and Sugar Logic may stress the otherwise simple process and cause issues with webheads and other resources being used in the process. If you are experiencing these symptoms, the following sections may help you. Disabling Related Calculation Fields
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Best_Practices/index.html
76ad35f93c68-1
Disabling Related Calculation Fields When a calculated field in Sugar uses the related function in the Sugar Logic, this will cause the calculated field to be executed when the related module is updated. This can cause a cascading effect through the system to update related calculated fields. When this happens you may receive a 502 Gateway Error. You can disable the related calculation field updates temporarily or permanently by adding the following line to the config_override.php file: $sugar_config['disable_related_calc_fields'] = true; Note : This is a global setting that will affect all modules. If you have a calculated field in Accounts that sums up all Opportunities for the account, setting this value to true will no longer update the opportunity account sum in Accounts until the account record itself is modified. However, if this setting is left disabled, the sum would update any time a related opportunity or the account is modified.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Best_Practices/index.html
76ad35f93c68-2
More information on this setting can be found in the core configuration settings. Disabling Logic Hooks When data is being migrated into Sugar, logic hooks may be adding unnecessary time to your API requests. It is highly recommended for you to disable any unnecessary logic hooks from your system during an initial import. Logic hook definitions may be located in the following files and/or directories: ./custom/modules/logic_hooks.php ./custom/modules/<module>/logic_hooks.php ./custom/Extension/application/Ext/LogicHooks/ ./custom/Extension/modules/<module>/Ext/LogicHooks/ Disabling Workflows
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Best_Practices/index.html
76ad35f93c68-3
Disabling Workflows When data is being migrated into Sugar, workflows may be adding unnecessary time to your API requests. It is highly recommended for you to disable any unnecessary workflows from your system during an initial import in Admin > Workflows. Queuing Data in the Job Queue One solution for long running requests is to send the data to the Job Queue to be processed by the cron. To accomplish this, make a file customization to add to the target processing function. For this article's use case, create  ./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/CustomCreateAccountJob.php and send any stored data to it for processing. Enter the following code in the php file: <?php function CustomCreateAccountJob($job) { if (!empty($job->data)) {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Best_Practices/index.html
76ad35f93c68-4
{ if (!empty($job->data)) { $account = BeanFactory::newBean('Accounts'); $fields = json_decode($job->data, true); foreach($fields as $field => $value) { $account->$field = $value; } $account->save(); if (!empty($account->id)) { return true; } } return false; } Next, modify the request to pass the new account data to the SchedulerJobs module in the data field and specify the new function in the target field, as follows:Â
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Best_Practices/index.html
76ad35f93c68-5
curl -v -H "oauth-token: 4afd4aea-df99-7cec-4d94-560a97cda9f8" -H "Content-Type: application/json" -X POST -d '{"assigned_user_id": "1", "name":"Queue Create Account", "status":"queued", "data":"{\"name\": \"Example Account\"}", "target":"function::CustomCreateAccountJob"}' http://<site_url>rest/v10/SchedulersJobs This solution will queue data for processing and free up system resources to send more requests. For more information, please refer to the Scheduler Jobs documentation. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Integration/Best_Practices/index.html
2c3eb51bca29-0
User Interface Overview Sugar's user interface is dependent on the client (i.e. base, mobile, or portal) being used to access the system. Clients are the various platforms that use Sugar's APIs to render the user interface. Each platform type will have a specific path for its components. While the Developer Guide mainly covers the base client type, the following sections will outline the various metadata locations. Clients Clients are the various platforms that access and use Sidecar to render content. Depending on the platform you are using, the layout, view, and metadata will be driven based on its client type. The following sections describe the client types. base The base client is the Sugar application that you use to access your data from a web browser. The framework's specific views, layouts, and fields are rendered using Sidecar.  Files specific to this client type can be found in the following directories:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/index.html
2c3eb51bca29-1
./clients/base/ ./custom/clients/base/ ./modules/<module>/clients/base/ ./custom/modules/<module>/clients/base/ mobile The mobile client is the SugarCRM mobile application that you use to access data from your mobile device. The framework-specific views, layouts, and fields for this application are found in the following directories: ./clients/mobile/ ./custom/clients/mobile/ ./modules/<module>/clients/mobile/ ./custom/modules/<module>/clients/mobile/ portal The portal client is the customer self-service portal application that comes with Sugar Enterprise and Sugar Ultimate. The framework-specific views, layouts, and fields for this application are found in the following directories: ./clients/portal/
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/index.html
2c3eb51bca29-2
./clients/portal/ ./custom/clients/portal/ ./modules/<module>/clients/portal/ ./custom/modules/<module>/clients/portal/
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/index.html
2c3eb51bca29-3
TopicsSidecarSidecar is a platform that moves processing to the client side to render pages as single-page web apps. Sidecar contains a complete Model-View-Controller (MVC) framework based on the Backbone.js library.EventsThe Backbone events module is a lightweight pub-sub pattern that gets mixed into each Backbone class (Model, View, Collection, Router, etc.). This means that you can listen to or dispatch custom named events from any Backbone object.RoutesRoutes determine where users are directed based on patterns in the URL.HandlebarsThe Handlebars library, located in ./sidecar/lib/handlebars/, is a JavaScript library that lets Sugar create semantic templates. Handlebars help render content for layouts, views, and fields for Sidecar. Using Handlebars, you can make modifications to the display of content such as adding HTML or CSS.LayoutsLayouts are component plugins that define the overall layout and positioning of the
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/index.html
2c3eb51bca29-4
HTML or CSS.LayoutsLayouts are component plugins that define the overall layout and positioning of the page. Layouts replace the previous concept of MVC views and are used system-wide to generate rows, columns, bootstrap fluid layouts, and pop-ups by wrapping and placing multiple views or nested layouts on a page.ViewsViews are component plugins that render data from a context. View components may contain field components and are typically made up of a controller JavaScript file (.js) and at least one Handlebars template (.hbs).FieldsFields are component plugins that render and format field values. They are made up of a controller JavaScript file (.js) and at least one Handlebars template (.hbt). For more information regarding the data handling of a field, please refer the data framework fields documentation. For information on creating custom field types, please refer the Creating Custom Field Types cookbook example.SubpanelsFor Sidecar, Sugar's subpanel layouts have been modified
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/index.html
2c3eb51bca29-5
Types cookbook example.SubpanelsFor Sidecar, Sugar's subpanel layouts have been modified to work as simplified metadata. This page is an overview of the metadata framework for subpanels.DashletsDashlets are special view-component plugins that render data from a context and make use of the Dashlet plugin. They are typically made up of a controller JavaScript file (.js) and at least one Handlebars template (.hbs).DrawersThe drawer layout widget, located in ./clients/base/layouts/drawer/, is used to display a window of additional content to the user. This window can then be closed to display the content the user was previously viewing.AlertsThe alert view widget, located in ./clients/base/views/alert/, displays helpful information such as loading messages, notices, and confirmation messages to the user.LanguageThe language library, located in ./sidecar/src/core/language.js, is used to manage the
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/index.html
2c3eb51bca29-6
located in ./sidecar/src/core/language.js, is used to manage the user's display language as well as fetch labels and lists. For more information on customizing languages, please visit the language framework documentation.MainLayoutSugar's Main navigation is split into two components: Top-Header and Sidebar. The Top-Header is primarily used for search, notifications, and user actions and the Sidebar is the primary tool used to navigate the front end of the Sugar application.Administration LinksAdministration links are the shortcut URLs found on the Administration page in the Sugar application. Developers can create additional administration links using the extension framework.Legacy MVCThe legacy MVC Architecture.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/index.html
2c3eb51bca29-7
Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/index.html
b29cf0092dab-0
Events Overview The Backbone events module is a lightweight pub-sub pattern that gets mixed into each Backbone class (Model, View, Collection, Router, etc.). This means that you can listen to or dispatch custom named events from any Backbone object. Backbone events should not be confused with a jQuery events, which are used for working with DOM events in an API. Backbone supports an events hash on views that can be used to attach event handlers to DOM using jQuery. These are not Backbone events. This can be confusing because, among other similarities, both interfaces include an on() function and allow you to attach an event handler. The targets for jQuery events are DOM elements. The target for Backbone events are Backbone objects. Sidecar classes extend these base Backbone classes. So each Sidecar object (Layouts, Views, Fields, Beans, Contexts, etc.) supports Backbone events.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Events/index.html
b29cf0092dab-1
Existing Backbone Event Catalog The current catalog of Backbone events is supported and triggered by the Sugar application. For example, we can listen to built-in Backbone router events, such as the route event, that is triggered by Sidecar. Try running the following JavaScript code from your browser's console: SUGAR.App.router.on('route', function(arguments) { console.log(arguments); }); As you click through the Sugar application, each time the router is called, you will see routing events appear in your browser console. Sidecar Events Global Application Events
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Events/index.html
b29cf0092dab-2
Sidecar Events Global Application Events Application events are all triggered on the app.events (SUGAR.App.events) object. Below is a list of application events with a description of when you can expect them to fire. However, please note that these events can be triggered in more than one place and some events, such as app:sync:error, can trigger events such as app:logout. Name Description app:init Triggered after the Sidecar application initializesNote: Initialization registers events, builds out Sidecar API objects, loads public metadata and config, and initializes modules. app:start Triggered after the Sidecar application starts app:sync Triggered when metadata is being synced with the user interface, for example, after login has occurred app:sync:complete Triggered after metadata has completely synced app:sync:error
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Events/index.html
b29cf0092dab-3
Triggered after metadata has completely synced app:sync:error Triggered when metadata sync fails app:sync:public:error Triggered when public metadata sync fails during initialization app:view:change Triggered when a new view is loaded app:locale:change Triggered when the locale changes lang:direction:change Triggered when the locale changes and the direction of the language is different app:login Triggered when the "Login" route is called app:login:success Triggered after a successful login app:logout Triggered when the application is logging out app:logout:success Triggered after a successful logout Bean Events The following table lists bean object events. Name Description acl:change Triggered when the ACLs change for that module acl:change:<fieldName>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Events/index.html
b29cf0092dab-4
acl:change:<fieldName> Triggered when the ACLs change for a particular field in that module validation:success Triggered when bean validation is valid validation:complete Triggered when bean validation completes error:validation Triggered when bean validation has an error error:validation:<fieldName> Triggered when a particular field has a bean validation error attributes:revert Triggered when the bean reverts to the previous attributes Context Events
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Events/index.html
b29cf0092dab-5
Triggered when the bean reverts to the previous attributes Context Events The context object is used to facilitate communication between different Sidecar components on the page using events. For example, the button:save_button:click event triggers whenever a user clicks the Save button. The record view uses this event to run Save routines without being tightly coupled to a particular Save button. A list of these contextual events is not plausible because the user interface is continuously changing between versions, and there are many more possibilities based on the views and layouts in each version. Utilizing Events Application events can be bound to in any custom JavaScript controller or any JavaScript file loaded into Sugar and included on the page (such as via JSGroupings framework). An example below shows how one could add custom JavaScript code to trigger after the application log out. ./custom/include/javascript/myAppLogoutSuccessEvent.js (function(app){
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Events/index.html
b29cf0092dab-6
(function(app){ app.events.on('app:logout:success', function(data) { //Add Logic Here console.log(data); }); })(SUGAR.App); With the custom event JavaScript file written and in place, include it into the system using the JSGroupings extension. ./custom/Extension/application/Ext/JSGroupings/myAppLogoutSuccessEvent.php foreach ($js_groupings as $key => $groupings) { foreach ($groupings as $file => $target) { //if the target grouping is found if ($target == 'include/javascript/sugar_grp7.min.js') { //append the custom JavaScript file
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Events/index.html
b29cf0092dab-7
//append the custom JavaScript file $js_groupings[$key]['custom/include/javascript/myAppLogoutSuccessEvent.js'] = 'include/javascript/sugar_grp7.min.js'; } break; } } Once in place, navigate to Admin > Repair > Rebuild JS Grouping Files. After the JSGroupings are rebuilt, clear your browser cache and the custom JavaScript will now trigger after a successful logout. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Events/index.html
5a3eb17b5c54-0
Routes Overview Routes determine where users are directed based on patterns in the URL. Routes Routes, defined in ./include/javascript/sugar7.js, are URL patterns signified by a hashtag ("#") in the URL. An example module URL pattern for the Sugar application is http://{site url}/#<module>. This route would direct a user to the list view for a given module. The following sections will outline routes and how they are defined. Route Definitions The router accepts route definitions in the following format: routes = [ { name: "My First Route", route: "pattern/to/match", callback: function() { //handling logic here. } }, {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Routes/index.html
5a3eb17b5c54-1
{ //handling logic here. } }, { name: "My Second Route", route: "pattern/:variable", callback: "<callback name>" } ] A route takes in three properties: the name of the route, the route pattern to match, and the callback to be called when the route is matched. If a default callback is desired, you can specify the callback name as a string. Route Patterns Route patterns determine where to direct the user. An example of routing is done when navigating to an account record. When doing this you may notice that your URL is: http://{site url}/#Accounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee A stock route's definition is defined in ./include/javascript/sugar7.js as: { name: "record",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Routes/index.html
5a3eb17b5c54-2
{ name: "record", route: ":module/:id" }, Variables in the route pattern are prefixed with a colon such as :variable. The route pattern above contains two variables: module id Custom Routes As of 7.8.x, you can add the routes during the initialization of the Router, so custom routes can be registered in the Sidecar router during both router:init and router:start events. It is recommended to register them in the Initialization event before any routing has occurred. There are two methods in the Sidecar Router, which allow for adding custom routes: route() Arguments Name Required Type Description route true string The Route pattern to be matched by the URL Fragment name true string  The unique name of the Route callback true
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Routes/index.html
5a3eb17b5c54-3
name true string  The unique name of the Route callback true function  The callback function for the Route Example The following example registers a custom Route during the router:init event, using the route() method. ./custom/javascript/customRoutes.js (function(app){ app.events.on("router:init", function(){ //Register the route #test/123 app.router.route("test/:id", "test123", function() { console.log(arguments); app.controller.loadView({ layout: "custom_layout", create: true }); }); }) })(SUGAR.App); addRoutes()
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Routes/index.html
5a3eb17b5c54-4
}) })(SUGAR.App); addRoutes() When you need to add multiple routes, you can define the routes in an array and pass the entire array to the addRoutes() method on the Sidecar Router to ensure they are registered. Please note, the addRoutes() method utilizes the above route() method to register the routes with the Backbone Router. The Backbone router redirects after the first matching route. Due to this, the order in which the routes are listed in the array is important as it will determine which route will be used by the application. It is recommended that the most specific routes be listed first in the array so that they are recognized first, instead of those routes which may contain a variable. Arguments Name Required Type Description routes true array An array of route definition as defined above. Example
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Routes/index.html
5a3eb17b5c54-5
routes true array An array of route definition as defined above. Example The following example registers custom Route during the router:init event, using the addRoutes() method. The route's JavaScript controller can exist anywhere you'd like. For our purposes, we created it in ./custom/javascript/customRoutes.js. This file will contain your custom route definitions. ./custom/javascript/customRoutes.js (function(app){ app.events.on("router:init", function(){ var routes = [ { route: 'test/doSomething', name: 'testDoSomething', callback: function(){ alert("Doing something..."); } }, { route: 'test/:id', name: 'test123',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Routes/index.html
5a3eb17b5c54-6
route: 'test/:id', name: 'test123', callback: function(){ console.log(arguments); app.controller.loadView({ layout: "custom_layout", create: true }); } } ]; app.router.addRoutes(routes); }) })(SUGAR.App); Next, create the JSGrouping extension. This file will allow Sugar to recognize that you've added custom routes.  ./custom/Extension/application/Ext/JSGroupings/myCustomRoutes.php <?php foreach ($js_groupings as $key => $groupings) {     $target = current(array_values($groupings));     //if the target grouping is found
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Routes/index.html
5a3eb17b5c54-7
    //if the target grouping is found     if ($target == 'include/javascript/sugar_grp7.min.js') {         //append the custom JavaScript file         $js_groupings[$key]['custom/javascript/customRoutes.js'] = 'include/javascript/sugar_grp7.min.js';     } } Once your files are in place, navigate to Admin > Repairs > Quick Repair & Rebuild. For additional information, please refer to the JSGroupings framework. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Routes/index.html
27b68c30aea2-0
Views Overview Views are component plugins that render data from a context. View components may contain field components and are typically made up of a controller JavaScript file (.js) and at least one Handlebars template (.hbs). Load Order Hierarchy Diagram The view components are loaded in the following manner: Note: The Sugar application's client type is "base". For more information on the various client types, please refer to the User Interface page. Components Views are made up of a controller and a Handlebar template. Controller
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/index.html
27b68c30aea2-1
Components Views are made up of a controller and a Handlebar template. Controller The view's controller is what controls the view in how data is loaded, formatted, and manipulated. The controller is the JavaScript file named after the view. A controller file can be found in any of the directories shown in the hierarchy diagram above. In the example of the record view, the main controller file is located in ./clients/base/views/record/record.js and any modules extending this controller will have a file located in ./modules/<module>/clients/base/views/record/record.js.   Handlebar Template
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/index.html
27b68c30aea2-2
Handlebar Template The views template is built on Handlebars and is what adds the display markup for the data. The template is typically named after the view or an action in the view. In the example of the record view, the main template us located in ./clients/base/views/record/record.hbs. This template will take the data fetched from the REST API to render the display for the user. More information on templates can be found in the Handlebars section. Extending Views When working with module views, it is important to understand the difference between overriding and extending a view. Overriding is essentially creating or copying a view to be used by your application that is not extending its parent. By default, some module views already extend the core ./clients/base/views/record/record.js controller. An example of this is the accounts RecordView
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/index.html
27b68c30aea2-3
./modules/Accounts/clients/base/views/record/record.js ({ extendsFrom: 'RecordView', /** * @inheritdoc */ initialize: function(options) { this.plugins = _.union(this.plugins || [], ['HistoricalSummary']); this._super('initialize', [options]); } })
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/index.html
27b68c30aea2-4
this._super('initialize', [options]); } }) As you can see, this view has the property: extendsFrom: 'RecordView'. This property tells Sidecar that the view is going to extend its parent RecordView. In addition to this, you can see that the initialize method is also calling this._super('initialize', [options]);. Calling this._super tells Sidecar to execute the parent function. The major benefit of doing this is that any updates to ./clients/base/views/record/record.js will be reflected for the module without any modifications being made to ./modules/Accounts/clients/base/views/record/record.js. You should note that when using extendsFrom, the parent views are called similarly to the load hierarchy:    Create View and Record View Inheritance
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/index.html
27b68c30aea2-5
  Create View and Record View Inheritance The diagram below demonstrates the inheritance of the create and record views for the Quotes module. This inheritance structure is the same for stock and custom modules alike.  Basic View Example A simple view for beginners is the access-denied view. The view is located in ./clients/base/views/access-denied/ and is what handles the display for restricted access. The sections below will outline the various files that render this view. Controller The access-denied.js, shown below, controls the manipulation actions of the view. ./clients/base/views/access-denied/access-denied.js ({ className: 'access-denied tcenter', cubeOptions: {spin: false}, events: { 'click .sugar-cube': 'spinCube' },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/index.html
27b68c30aea2-6
'click .sugar-cube': 'spinCube' }, spinCube: function() { this.cubeOptions.spin = !this.cubeOptions.spin; this.render(); } }) Attributes Attribute Description className The CSS class to apply to the view. cubeOptions A set of options that are passed to the spinCube function when called. events A list of the view events. This view executes the spinCube function when the sugar cube is clicked. spinCube Function to control the start and stop of the cube spinning. Handlebar Template The access-denied.hbs file defines the format of the views content. As this view is used for restricting access, it displays a message to the user describing the restriction. ./clients/base/views/access-denied/access-denied.hbs
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/index.html
27b68c30aea2-7
<div class="error-message"> <h1>{{str 'ERR_NO_VIEW_ACCESS_TITLE'}}</h1> <p>{{str 'ERR_NO_VIEW_ACCESS_REASON'}}</p> <p>{{str 'ERR_NO_VIEW_ACCESS_ACTION'}}</p> </div> {{{subFieldTemplate 'sugar-cube' 'detail' cubeOptions}}} Helpers Name Description str Handlebars helper to render the label string subFieldTemplate Handlebars helper to render the cube content Cookbook Examples When working with views, you may find the follow cookbook examples helpful: Adding Buttons to the Record View Adding Field Validation to the Record View Passing_Data_to_Templates
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/index.html
27b68c30aea2-8
Adding Field Validation to the Record View Passing_Data_to_Templates TopicsMetadataThis page is an overview of the metadata framework for Sidecar modules. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/index.html
6222ec060a60-0
Metadata Overview This page is an overview of the metadata framework for Sidecar modules. View Metadata Framework A module's view-specific metadata can be found in the modules view file: ./modules/<module>/clients/<client>/views/<view>/<view>.php Any edits made in Admin > Studio will be reflected in the file: ./custom/modules/<module>/clients/<client>/views/<view>/<view>.php Note: The Sugar application's client type is "base". For more information on the various client types, please refer to the User Interface page. Note: In the case of metadata, custom view metadata files are respected over the stock view metadata files. View Metadata The Sidecar views metadata is very similar to that of the MVC metadata, however, there are some basic differences. All metadata for Sidecar follows the format:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-1
$viewdefs['<module>']['base']['view']['<view>'] = array(); An example of this is the account's record layout shown below: ./modules/Accounts/clients/base/views/record/record.php <?php $viewdefs['Accounts']['base']['view']['record'] = array( 'panels' => array( array( 'name' => 'panel_header', 'header' => true, 'fields' => array( array( 'name' => 'picture', 'type' => 'avatar', 'width' => 42, 'height' => 42, 'dismiss_label' => true, 'readonly' => true, ), 'name',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-2
'readonly' => true, ), 'name', array( 'name' => 'favorite', 'label' => 'LBL_FAVORITE', 'type' => 'favorite', 'dismiss_label' => true, ), array( 'name' => 'follow', 'label'=> 'LBL_FOLLOW', 'type' => 'follow', 'readonly' => true, 'dismiss_label' => true, ), ) ), array( 'name' => 'panel_body', 'columns' => 2, 'labelsOnTop' => true, 'placeholders' => true, 'fields' => array( 'website', 'industry',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-3
'fields' => array( 'website', 'industry', 'parent_name', 'account_type', 'assigned_user_name', 'phone_office', ), ), array( 'name' => 'panel_hidden', 'hide' => true, 'columns' => 2, 'labelsOnTop' => true, 'placeholders' => true, 'fields' => array( array( 'name' => 'fieldset_address', 'type' => 'fieldset', 'css_class' => 'address', 'label' => 'Billing Address', 'fields' => array( array( 'name' => 'billing_address_street',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-4
array( 'name' => 'billing_address_street', 'css_class' => 'address_street', 'placeholder' => 'LBL_BILLING_ADDRESS_STREET', ), array( 'name' => 'billing_address_city', 'css_class' => 'address_city', 'placeholder' => 'LBL_BILLING_ADDRESS_CITY', ), array( 'name' => 'billing_address_state', 'css_class' => 'address_state', 'placeholder' => 'LBL_BILLING_ADDRESS_STATE', ), array( 'name' => 'billing_address_postalcode',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-5
'name' => 'billing_address_postalcode', 'css_class' => 'address_zip', 'placeholder' => 'LBL_BILLING_ADDRESS_POSTALCODE', ), array( 'name' => 'billing_address_country', 'css_class' => 'address_country', 'placeholder' => 'LBL_BILLING_ADDRESS_COUNTRY', ), ), ), array( 'name' => 'fieldset_shipping_address', 'type' => 'fieldset', 'css_class' => 'address', 'label' => 'Shipping Address', 'fields' => array( array( 'name' => 'shipping_address_street',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-6
array( 'name' => 'shipping_address_street', 'css_class' => 'address_street', 'placeholder' => 'LBL_SHIPPING_ADDRESS_STREET', ), array( 'name' => 'shipping_address_city', 'css_class' => 'address_city', 'placeholder' => 'LBL_SHIPPING_ADDRESS_CITY', ), array( 'name' => 'shipping_address_state', 'css_class' => 'address_state', 'placeholder' => 'LBL_SHIPPING_ADDRESS_STATE', ), array( 'name' => 'shipping_address_postalcode',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-7
'name' => 'shipping_address_postalcode', 'css_class' => 'address_zip', 'placeholder' => 'LBL_SHIPPING_ADDRESS_POSTALCODE', ), array( 'name' => 'shipping_address_country', 'css_class' => 'address_country', 'placeholder' => 'LBL_SHIPPING_ADDRESS_COUNTRY', ), array( 'name' => 'copy', 'label' => 'NTC_COPY_BILLING_ADDRESS', 'type' => 'copy', 'mapping' => array( 'billing_address_street' => 'shipping_address_street',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-8
'billing_address_street' => 'shipping_address_street', 'billing_address_city' => 'shipping_address_city', 'billing_address_state' => 'shipping_address_state', 'billing_address_postalcode' => 'shipping_address_postalcode', 'billing_address_country' => 'shipping_address_country', ), ), ), ), array( 'name' => 'phone_alternate', 'label' => 'LBL_OTHER_PHONE', ), 'email', 'phone_fax', 'campaign_name', array( 'name' => 'description', 'span' => 12, ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-9
'name' => 'description', 'span' => 12, ), 'sic_code', 'ticker_symbol', 'annual_revenue', 'employees', 'ownership', 'rating', array( 'name' => 'date_entered_by', 'readonly' => true, 'type' => 'fieldset', 'label' => 'LBL_DATE_ENTERED', 'fields' => array( array( 'name' => 'date_entered', ), array( 'type' => 'label', 'default_value' => 'LBL_BY', ), array( 'name' => 'created_by_name', ), ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-10
'name' => 'created_by_name', ), ), ), 'team_name', array( 'name' => 'date_modified_by', 'readonly' => true, 'type' => 'fieldset', 'label' => 'LBL_DATE_MODIFIED', 'fields' => array( array( 'name' => 'date_modified', ), array( 'type' => 'label', 'default_value' => 'LBL_BY', ), array( 'name' => 'modified_by_name', ), ), ), ), ), ), );
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
6222ec060a60-11
), ), ), ), ), ), ); The metadata for a given view can be accessed using app.metadata.getView within your controller. An example fetching the view metadata for the Accounts RecordView is shown below: app.metadata.getView('Accounts', 'record'); You should note that this can also be accessed in your browser's console window by using the global App Identifier: App.metadata.getView('Accounts', 'record'); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Views/Metadata/index.html
5d5755217b0b-0
Handlebars Overview The Handlebars library, located in ./sidecar/lib/handlebars/, is a JavaScript library that lets Sugar create semantic templates. Handlebars help render content for layouts, views, and fields for Sidecar. Using Handlebars, you can make modifications to the display of content such as adding HTML or CSS.   For more information on the Handlebars library, please refer to their website at http://handlebarsjs.com.  Templates The Handlebars templates are stored in the filesystem as .hbs files. These files are stored along with the view, layout, and field metadata and are loaded according to the inheritance you have selected in your controller. To view the list of available templates, or to see if a custom-created template is available, you can open your browser's console window and inspect the Handlebars.templates namespace. Debugging Templates
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Handlebars/index.html
5d5755217b0b-1
Debugging Templates When working with Handlebar templates, it can be difficult to identify where an issue is occurring or what a variable contains. To assist with troubleshooting this, you can use the log helper. The log helper will output the contents of this and the variable passed to it in your browser's console. This is an example of using the logger in a handlebars template: {{log this}} Helpers Handlebar Helpers are a way of adding custom functionality to the templates. Helpers are located in the following places: ./sidecar/src/view/hbs-helpers.js : Sidecar uses these helpers by default ./include/javascript/sugar7/hbs-helpers.js : Additional helpers used by the base client Creating Helpers When working with Handlebar templates, you may need to create your helper. To do this, follow these steps:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Handlebars/index.html
5d5755217b0b-2
Create a Handlebars helper file in the ./custom/ directory. For this example, we will create two functions to convert a string to uppercase or lowercase: ./custom/JavaScript/my-handlebar-helpers.js  /** * Handlebars helpers. * * These functions are to be used in handlebars templates. * @class Handlebars.helpers * @singleton */ (function(app) { app.events.on("app:init", function() { /** * convert a string to upper case */ Handlebars.registerHelper("customUpperCase", function (text) { return text.toUpperCase(); }); /** * convert a string to lower case */ Handlebars.registerHelper("customLowerCase", function (text) {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Handlebars/index.html
5d5755217b0b-3
Handlebars.registerHelper("customLowerCase", function (text) { return text.toLowerCase(); }); }); })(SUGAR.App); Next, create a JSGrouping extension in ./custom/Extension/application/Ext/JSGroupings/. Name the file uniquely for your customization. For this example, we will create:  ./custom/Extension/application/Ext/JSGroupings/my-handlebar-helpers.php <?php //Loop through the groupings to find include/javascript/sugar_grp7.min.js foreach($js_groupings as $key => $groupings) { foreach($groupings as $file => $target) { if ($target == 'include/javascript/sugar_grp7.min.js') {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Handlebars/index.html
5d5755217b0b-4
//append the custom helper file $js_groupings[$key]['custom/JavaScript/my-handlebar-helpers.js'] = 'include/javascript/sugar_grp7.min.js'; } break; } } Finally, navigate to Admin > Repair and perform the following two repair sequences to include the changes: Quick Repair and Rebuild Rebuild JS Groupings. You can now use your custom helpers in the HBS files by using: {{customUpperCase "MyString"}} {{customLowerCase "MyString"}} Note: You can also access the helpers function from your browsers developer console using Handlebars.helpers Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Handlebars/index.html
860d66257fda-0
Language Overview The language library, located in ./sidecar/src/core/language.js, is used to manage the user's display language as well as fetch labels and lists. For more information on customizing languages, please visit the language framework documentation. Methods app.lang.get(key, module, context) The app.lang.get(key, module, context) method fetches a string for a given key. The method searches the module strings first and then falls back to the app strings. If the label is a template, it will be compiled and executed with the given context. Parameters Name Required Description key yes The key of the string to retrieve module no The Sugar module that the label belongs to context no Template context Example app.lang.get('LBL_NAME', 'Accounts'); app.lang.getAppString(key)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Language/index.html
860d66257fda-1
app.lang.getAppString(key) The app.lang.getAppString(key) method retrieves an application string for a given key. Parameters Name Required Description key yes The key of the string to retrieve Example app.lang.getAppString('LBL_MODULE'); app.lang.getAppListStrings(key) The app.lang.getAppListStrings(key) method retrieves an application list string or object. Parameters Name Required Description key yes The key of the string to retrieve Example app.lang.getAppListStrings('sales_stage_dom'); app.lang.getModuleSingular(moduleKey) The app.lang.getModuleSingular(moduleKey) method retrieves an application list string or object. Parameters Name Required Description moduleKey yes
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Language/index.html
860d66257fda-2
Parameters Name Required Description moduleKey yes The module key of the singular module label to retrieve Example app.lang.getModuleSingular("Accounts"); app.lang.getLanguage() The app.lang.getLanguage() method retrieves the current user's language key. Example app.lang.getLanguage(); app.lang.updateLanguage(languageKey) The app.lang.updateLanguage(languageKey) method updates the current user's language key. Parameters Name Required Description languageKey yes Language key of the language to set for the user Example app.lang.updateLanguage('en_us'); Testing in Console To test out the language library, you can trigger actions in your browsers developer tools by using the global Apps variable as shown below: App.lang.getAppListStrings('sales_stage_dom');
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Language/index.html
860d66257fda-3
App.lang.getAppListStrings('sales_stage_dom'); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Language/index.html
29e389b13ae3-0
Fields   Overview Fields are component plugins that render and format field values. They are made up of a controller JavaScript file (.js) and at least one Handlebars template (.hbt). For more information regarding the data handling of a field, please refer the data framework fields documentation. For information on creating custom field types, please refer the Creating Custom Field Types cookbook example. Hierarchy Diagram The field components are loaded in the following manner: Note: The Sugar application's client type is "base". For more information on the various client types, please refer to the User Interface page. Field Example The bool field, located in ./clients/base/fields/bool/, handles the display of checkbox boolean values. The sections below outline the various files that render this field type. Controller
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Fields/index.html
29e389b13ae3-1
Controller The bool.js, file is shown below, overrides the base _render function to disable the field. The format and unformat functions handle the manipulation of the field's value. ./clients/base/fields/bool/bool.js ({ _render: function() { app.view.Field.prototype._render.call(this); if(this.tplName === 'disabled') { this.$(this.fieldTag).attr("disabled", "disabled"); } }, unformat:function(value){ value = this.$el.find(".checkbox").prop("checked") ? "1" : "0"; return value; }, format:function(value){ value = (value=="1") ? true : false; return value; } }) Attributes Attribute Description
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Fields/index.html
29e389b13ae3-2
return value; } }) Attributes Attribute Description _render Function to render the field. unformat Function to dynamically check the checkbox based on the value. format Function to format the value for storing in the database. Handlebar Templates The edit.hbs file defines the display of the control when the edit view is used. This layout is for displaying the editable form element that renders a clickable checkbox control for the user. ./clients/base/fields/bool/edit.hbs {{#if def.text}} <label> <input type="checkbox" class="checkbox"{{#if value}} checked{{/if}}> {{str def.text this.module}} </label> {{else}} <input type="checkbox" class="checkbox"{{#if value}} checked{{/if}}>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Fields/index.html
29e389b13ae3-3
{{/if}} Helpers Helpers Description str Handlebars helper to render the label string. The detail.hbs file defines the display of the control when the detail view is used. This layout is for viewing purposes only so the control is disabled by default. ./clients/base/fields/bool/detail.hbs <input type="checkbox" class="checkbox"{{#if value}} checked{{/if}} disabled> The list.hbs file defines the display of the control when the list view is used. This view is also for viewing purposes only so the control is disabled by default. ./clients/base/fields/bool/list.hbs <input type="checkbox" class="checkbox"{{#if value}} checked{{/if}} disabled> Cookbook Examples When working with fields, you may find the follow cookbook examples helpful:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Fields/index.html
29e389b13ae3-4
Cookbook Examples When working with fields, you may find the follow cookbook examples helpful: Creating Custom Field Types Converting Address' Country Field to a Dropdown Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Fields/index.html
940c7c70eeca-0
Sidecar Overview Sidecar is a platform that moves processing to the client side to render pages as single-page web apps. Sidecar contains a complete Model-View-Controller (MVC) framework based on the Backbone.js library. By creating a single-page web app, server load drastically decreases while the client's performance increases because the application is sending pure JSON data in place of HTML. The JSON data, returned by the v10 API, defines the application's modules, records, and ACLs, allowing UI processing to happen on the client side and significantly reducing the amount of data to transfer.    Composition Sidecar contains the following parts, which are briefly explained in the sections below: Backbone.js Components (Layouts, Views, and Fields) Context Backbone.js
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Sidecar/index.html
940c7c70eeca-1
Context Backbone.js Backbone.js is a lightweight JavaScript framework based on MVP (model–view–presenter) application design. It allows developers to easily interact with a RESTful JSON API to fetch models and collections for use within their user interface. For more information about Backbone.js, please refer to their documentation at Backbone.js. Components Everything that is renderable on the page is a component. A layout is a component that serves as a canvas for one or more views and other layouts. All pages will have at least one master layout, and that master layout can contain multiple nested layouts. Layouts Layouts are components that render the overall page. They define the rows, columns, and fluid layouts of content that gets delivered to the end user. Example layouts include: Rows Columns Bootstrap fluid layouts Drawers and dropdowns
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Sidecar/index.html
940c7c70eeca-2
Rows Columns Bootstrap fluid layouts Drawers and dropdowns For more information about the various layouts, please refer to the Layouts page of this documentation. Views Views are components that render data from a context and may or may not include field components. Example views include not only record and list views but also widgets such as: Graphs or other data visualizations External data views such as Twitter, LinkedIn, or other web service integrations The global header For more information about views, please refer to the Views page of this documentation. Fields Fields render widgets for individual values that have been pulled from the models and also handle formatting (or stripping the formatting of) field values. Like layouts and views, fields extend Backbone views.  For more information about the various layouts, please refer to the Fields page of this documentation. Context
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Sidecar/index.html
940c7c70eeca-3
Context A Context is a container for the relevant data for a page, and it has three major attributes: Module : The name of the module this context is based on Model : The primary or selected model for this context Collection : The set of models currently loaded in this context Contexts are used to retrieve related data and to paginate through lists of data.   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Sidecar/index.html
86e14e828b42-0
Drawers Overview The drawer layout widget, located in ./clients/base/layouts/drawer/, is used to display a window of additional content to the user. This window can then be closed to display the content the user was previously viewing. Methods app.drawer.open(layoutDef, onClose) The app.drawer.open(layoutDef, onClose) method displays a new content window over the current view. Parameters Name Required Description layoutDef.layout yes The id of the layout to load. layoutDef.context no Additional data you would like to pass to the drawer. Data passed in can be retrieved from the view using: this.context.get('<data key>');
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Drawers/index.html
86e14e828b42-1
this.context.get('<data key>'); Note: Be very careful about what you pass in as data to the drawer. As the data is passed in by reference, when the drawer is closed, the context is destroyed. onClose no Optional callback handler for when the drawer is closed. Example app.drawer.open({ layout: 'my-layout', context: { myData: data }, }, function() { //on close, throw an alert alert('Drawer closed.'); }); app.drawer.close(callbackOptions) The app.drawer.close(callbackOptions) method dismisses the topmost drawer. Parameters Name Required Description callbackOptions no Any parameters passed into the close method will be passed to the callback. Standard Example app.drawer.close(); Callback Example
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Drawers/index.html
86e14e828b42-2
Standard Example app.drawer.close(); Callback Example //open drawer app.drawer.open({ layout: 'my-layout', }, function(message1, message2) { alert(message1); alert(message2); }); //close drawer app.drawer.close('message 1', 'message 2'); app.drawer.load(options) Loads a new layout into an existing drawer. Parameters Name Description options.layout The id of the layout to load. Example app.drawer.load({ layout: 'my-second-layout', }); app.drawer.reset(triggerBefore) The app.drawer.reset(triggerBefore) method destroys all drawers at once. By default, whenever the application is routed to another page, reset() is called. Parameters Name Required
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Drawers/index.html
86e14e828b42-3
Parameters Name Required Description triggerBefore no Determines whether to triggerBefore. Defaults to false. Example app.drawer.reset(); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Drawers/index.html
a94a9bbd2b42-0
Subpanels Overview For Sidecar, Sugar's subpanel layouts have been modified to work as simplified metadata. This page is an overview of the metadata framework for subpanels.  The reason for this change is that previous versions of Sugar generated the metadata from various sources such as the SubPanelLayout and MetaDataManager classes. This eliminates the need for generating and processing the layouts and allows the metadata to be easily loaded to Sidecar. Note: Modules running in backward compatibility mode do not use the Sidecar subpanel layouts as they use the legacy MVC framework. Hierarchy Diagram When loading the Sidecar subpanel layouts, the system processes the layout in the following manner: Note: The Sugar application's client type is "base". For more information on the various client types, please refer to the User Interface page. Subpanels and Subpanel Layouts
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-1
Subpanels and Subpanel Layouts Sugar contains both a subpanels (plural) layout and a subpanel (singular) layout. The subpanels layout contains the collection of subpanels, whereas the subpanel layout renders the actual subpanel widget. An example of a stock module's subpanels layout is: ./modules/Bugs/clients/base/layouts/subpanels/subpanels.php <?php $viewdefs['Bugs']['base']['layout']['subpanels'] = array ( 'components' => array ( array ( 'layout' => 'subpanel', 'label' => 'LBL_DOCUMENTS_SUBPANEL_TITLE', 'context' => array ( 'link' => 'documents', ), ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-2
'link' => 'documents', ), ), array ( 'layout' => 'subpanel', 'label' => 'LBL_CONTACTS_SUBPANEL_TITLE', 'context' => array ( 'link' => 'contacts', ), ), array ( 'layout' => 'subpanel', 'label' => 'LBL_ACCOUNTS_SUBPANEL_TITLE', 'context' => array ( 'link' => 'accounts', ), ), array ( 'layout' => 'subpanel', 'label' => 'LBL_CASES_SUBPANEL_TITLE', 'context' => array ( 'link' => 'cases', ), ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-3
'link' => 'cases', ), ), ), 'type' => 'subpanels', 'span' => 12, ); You can see that the layout incorporates the use of the subpanel layout for each module. As most of the subpanel data is similar, this approach allows us to use less duplicate code. The subpanel layout, shown below, shows the three views that make up the subpanel widgets users see. ./clients/base/layouts/subpanel/subpanel.php <?php $viewdefs['base']['layout']['subpanel'] = array ( 'components' => array ( array ( 'view' => 'panel-top', ) array ( 'view' => 'subpanel-list', ), array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-4
'view' => 'subpanel-list', ), array ( 'view' => 'list-bottom', ), ), 'span' => 12, 'last_state' => array( 'id' => 'subpanel' ), ); Adding Subpanel Layouts When a new relationship is deployed from Studio, the relationship creation process will generate the layouts using the extension framework. You should note that for stock relationships and custom deployed relationships, layouts are generated for both Sidecar and Legacy MVC Subpanel formats. This is done to ensure that any related modules, whether in Sidecar or Backward Compatibility mode, display a related subpanel as expected. Sidecar Layouts
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-5
Sidecar Layouts Custom Sidecar layouts, located in ./custom/Extension/modules/<module>/Ext/clients/<client>/layouts/subpanels/, are compiled into ./custom/modules/<module>/Ext/clients/<client>/layouts/subpanels/subpanels.ext.php using the extension framework. When a relationship is saved, layout files are created for both the "base" and "mobile" client types. For example, deploying a 1:M relationship from Bugs to Leads will generate the following Sidecar files: ./custom/Extension/modules/Bugs/Ext/clients/base/layouts/subpanels/bugs_leads_1_Bugs.php <?php $viewdefs['Bugs']['base']['layout']['subpanels']['components'][] = array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-6
'layout' => 'subpanel', 'label' => 'LBL_BUGS_LEADS_1_FROM_LEADS_TITLE', 'context' => array ( 'link' => 'bugs_leads_1', ), ); ./custom/Extension/modules/Bugs/Ext/clients/mobile/layouts/subpanels/bugs_leads_1_Bugs.php <?php $viewdefs['Bugs']['mobile']['layout']['subpanels']['components'][] = array ( 'layout' => 'subpanel', 'label' => 'LBL_BUGS_LEADS_1_FROM_LEADS_TITLE', 'context' => array ( 'link' => 'bugs_leads_1',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-7
array ( 'link' => 'bugs_leads_1', ), ); Note: The additional legacy MVC layouts generated by a relationships deployment are described below. Legacy MVC Subpanel Layouts Custom Legacy MVC Subpanel layouts, located in ./custom/Extension/modules/<module>/Ext/Layoutdefs/, are compiled into ./custom/modules/<module>/Ext/Layoutdefs/layoutdefs.ext.php using the extension framework. You should also note that when a relationship is saved, wireless layouts, located in ./custom/Extension/modules/<module>/Ext/WirelessLayoutdefs/, are created and compiled into ./custom/modules/<module>/Ext/Layoutdefs/layoutdefs.ext.php. An example of this is when deploying a 1-M relationship from Bugs to Leads, the following layoutdef files are generated:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-8
./custom/Extension/modules/Bugs/Ext/Layoutdefs/bugs_leads_1_Bugs.php <?php $layout_defs["Bugs"]["subpanel_setup"]['bugs_leads_1'] = array ( 'order' => 100, 'module' => 'Leads', 'subpanel_name' => 'default', 'sort_order' => 'asc', 'sort_by' => 'id', 'title_key' => 'LBL_BUGS_LEADS_1_FROM_LEADS_TITLE', 'get_subpanel_data' => 'bugs_leads_1', 'top_buttons' => array ( 0 => array ( 'widget_class' => 'SubPanelTopButtonQuickCreate',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-9
array ( 'widget_class' => 'SubPanelTopButtonQuickCreate', ), 1 => array ( 'widget_class' => 'SubPanelTopSelectButton', 'mode' => 'MultiSelect', ), ), ); ./custom/Extension/modules/Bugs/Ext/WirelessLayoutdefs/bugs_leads_1_Bugs.php <?php $layout_defs["Bugs"]["subpanel_setup"]['bugs_leads_1'] = array ( 'order' => 100, 'module' => 'Leads', 'subpanel_name' => 'default', 'title_key' => 'LBL_BUGS_LEADS_1_FROM_LEADS_TITLE',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-10
'get_subpanel_data' => 'bugs_leads_1', ); Fields Metadata Sidecar's subpanel field layouts are initially defined by the subpanel list-view metadata. Hierarchy Diagram The subpanel list metadata is loaded in the following manner: Note: The Sugar application's client type is "base". For more information on the various client types, please refer to the User Interface page. Subpanel List Views By default, all modules come with a default set of subpanel fields for when they are rendered as a subpanel. An example of this is can be found in the Bugs module: ./modules/Bugs/clients/base/views/subpanel-list/subpanel-list.php <?php $subpanel_layout['list_fields'] = array ( 'full_name' => array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-11
'full_name' => array ( 'type' => 'fullname', 'link' => true, 'studio' => array ( 'listview' => false, ), 'vname' => 'LBL_NAME', 'width' => '10%', 'default' => true, ), 'date_entered' => array ( 'type' => 'datetime', 'studio' => array ( 'portaleditview' => false, ), 'readonly' => true, 'vname' => 'LBL_DATE_ENTERED', 'width' => '10%', 'default' => true, ), 'refered_by' => array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-12
), 'refered_by' => array ( 'vname' => 'LBL_LIST_REFERED_BY', 'width' => '10%', 'default' => true, ), 'lead_source' => array ( 'vname' => 'LBL_LIST_LEAD_SOURCE', 'width' => '10%', 'default' => true, ), 'phone_work' => array ( 'vname' => 'LBL_LIST_PHONE', 'width' => '10%', 'default' => true, ), 'lead_source_description' => array ( 'name' => 'lead_source_description',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-13
array ( 'name' => 'lead_source_description', 'vname' => 'LBL_LIST_LEAD_SOURCE_DESCRIPTION', 'width' => '10%', 'sortable' => false, 'default' => true, ), 'assigned_user_name' => array ( 'name' => 'assigned_user_name', 'vname' => 'LBL_LIST_ASSIGNED_TO_NAME', 'widget_class' => 'SubPanelDetailViewLink', 'target_record_key' => 'assigned_user_id', 'target_module' => 'Employees', 'width' => '10%', 'default' => true, ), 'first_name' => array (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-14
), 'first_name' => array ( 'usage' => 'query_only', ), 'last_name' => array ( 'usage' => 'query_only', ), 'salutation' => array ( 'name' => 'salutation', 'usage' => 'query_only', ), ); To modify this layout, navigate to Admin > Studio > {Parent Module} > Subpanels > Bugs and make your changes. Once saved, Sugar will generate ./custom/modules/Bugs/clients/<client>/views/subpanel-for-<link>/subpanel-for-<link>.php which will be used for rendering the fields you selected.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
a94a9bbd2b42-15
You should note that, just as Sugar mimics the Sidecar layouts in the legacy MVC framework for modules in backward compatibility, it also mimics the field list in ./modules/<module>/metadata/subpanels/default.php and ./custom/modules/<module>/metadata/subpanels/default.php. This is done to ensure that any related modules, whether in Sidecar or Backward Compatibility mode, display the same field list as expected. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Subpanels/index.html
03b2aa7c2e73-0
MainLayout Overview Sugar's Main navigation is split into two components: Top-Header and Sidebar. The Top-Header is primarily used for search, notifications, and user actions and the Sidebar is the primary tool used to navigate the front end of the Sugar application. Layout Components The Main layout is composed of Top-Header (header-nav) and Sidebar/Rail (sidebar-nav) layouts, and each of those layouts host views.  Top Header (header-nav)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-1
Top Header (header-nav) The Top Header (header-nav) layout, located in ./clients/base/layouts/header-nav/header-nav.php, is composed of the quicksearch layout as well as the header-nav-logos,  notifications, profileactions views. To customize these components, you can create your own layout by extending it at ./custom/Extension/application/Ext/custom/clients/base/layouts/header-nav/header-nav.php to reference your own custom components.   Sidebar/Rail (sidebar-nav) The Sidebar/Rail layout hosts overall Menu options by grouping them into layouts separated by a line/divisor within the sidebar-nav definition. Rail is collapsed by default and contains two main clickable actions: Primary and Secondary.  Link Actions
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-2
Link Actions The following properties define the navigation, display, and visibility of all links in the system: Name Description acl_action The ACL action is used to verify the user has access to a specific action required for the link acl_module The ACL module is used to verify if the user has access to a specific module required for the link icon The bootstrap icon to display next to the link (the full list of icons are listed in Admin > Styleguide > Core Elements > Base CSS > Icons) label The label key that contains your link's display text openwindow Specifies whether or not the link should open in a new window route
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-3
Specifies whether or not the link should open in a new window route The route to direct the user. For sidecar modules, this is #<module>, but modules in backward compatibility mode are routed as #bwc/index.php?module=<module>. Note: External links require the full URL as well as openwindow set to true. flyoutComponents An array of sub-navigation linksNote: Sub-navigation links contain these same basic link properties. Primary Action Primary actions are triggered by the click of a button on the sidebar-nav's views. By default if a route property is provided in the view object in the layout metadata, the Primary Action will be a link to the route provided. For example: $viewdefs[...] = [ 'layout' => [
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-4
$viewdefs[...] = [ 'layout' => [ 'type' => 'sidebar-nav-item-group', 'name' => 'sidebar-nav-item-group-bottom', 'css_class' => 'flex-grow-0 flex-shrink-0', 'components' => [ [ 'view' => [ 'name' => 'greeting-nav-item', 'type' => '<some-custom-view>', 'route' => '#Accounts', ... ], ], ], ], ]; Otherwise, if you're using a custom view and the controller has a primaryActionOnClick method defined, that will be used in addition to the route property.  Secondary Action
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-5
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. Secondary Actions do have some default behavior. If the template has the following markup present, the kebab will render on hover: <button class="sidebar-nav-item-kebab bg-transparent absolute p-0 h-full"> <i class="{{buildIcon 'sicon-kebab'}} text-white"></i> </button> If metadata is provided with certain keys, clicking on the kebab icon will render a flyout menu, for example, a metadata definition such as: <?php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-6
<?php $viewdefs['base']['layout']['sidebar-nav']['components'][] = [ 'layout' => [ 'type' => 'sidebar-nav-item-group', 'name' => 'sidebar-nav-item-group-bottom', 'css_class' => 'flex-grow-0 flex-shrink-0', 'components' => [ [ 'view' => [ 'name' => 'greeting-nav-item', 'type' => 'greeting-nav-item', 'route' => '#Accounts', 'icon' => 'sicon-bell-lg', 'label' => 'Hello!', 'flyoutComponents' => [ [
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-7
'flyoutComponents' => [ [ 'view' => 'sidebar-nav-flyout-header', 'title' => 'Greetings', ], [ 'view' => [ 'type' => 'sidebar-nav-flyout-actions', 'actions' => [ [ 'route' => '#Accounts', 'label' => 'LBL_ACCOUNTS', 'icon' => 'sicon-account-lg', ], ], ], ], ], ], ], ], ], ];
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/MainLayout/index.html
03b2aa7c2e73-8
], ], ], ], ], ], ]; The flyoutComponents array will render all the views that are passed to it. In this case, we load a sidebar-nav-item-header component and a sidebar-nav-item-flyout-actions component. Similar to a Primary Action, you can override the default secondaryActionOnClick method in your custom view controller to change the behavior of clicking on the kebab menu.  $viewdefs[...] = [ '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/User_Interface/MainLayout/index.html