id
stringlengths
14
16
text
stringlengths
33
5.27k
source
stringlengths
105
270
9bedf6bf84d1-15
<?php Sugarcrm\Sugarcrm\Console\CommandRegistry\CommandRegistry::getInstance() ->addCommand(new Sugarcrm\Sugarcrm\custom\Console\Command\<Command Class Name>()); Next, navigate to Admin > Repair > Quick Repair and Rebuild. The custom command will now be available. Example The following sections demonstrate how to create a "Hello World" example. This command does not alter the Sugar system and will only output display text. First, create the command class under the appropriate namespace. ./custom/src/Console/Command/HelloWorldCommand.php <?php namespace Sugarcrm\Sugarcrm\custom\Console\Command; use Sugarcrm\Sugarcrm\Console\CommandRegistry\Mode\InstanceModeInterface; use Symfony\Component\Console\Command\Command;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/CLI/index.html
9bedf6bf84d1-16
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * * Hello World Example * */ class HelloWorldCommand extends Command implements InstanceModeInterface { protected function configure() { $this ->setName('sugardev:helloworld') ->setDescription('Hello World') ->setHelp('This command accepts no paramters and returns "Hello World".') ; } protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln("Hello world -> " . $this->getApplication()->getMode()); } } Next, register the new command:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/CLI/index.html
9bedf6bf84d1-17
} } Next, register the new command: ./custom/Extension/application/Ext/Console/RegisterHelloWorldCommand.php <?php // Register HelloWorldCommand Sugarcrm\Sugarcrm\Console\CommandRegistry\CommandRegistry::getInstance() ->addCommand(new Sugarcrm\Sugarcrm\custom\Console\Command\HelloWorldCommand()); Navigate to Admin > Repair > Quick Repair and Rebuild. The new command will be executable from the root of the Sugar instance. It can be executed by running the following command: php bin/sugarcrm sugardev:helloworld  Result: Hello world -> InstanceMode Help text can be displayed by executing the following command:  php bin/sugarcrm help sugardev:helloworld  Result:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/CLI/index.html
9bedf6bf84d1-18
 Result: Usage: sugardev:helloworld Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --profile Display timing and memory usage information -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: This command accepts no paramters and returns "Hello World". Download the module loadable example package here. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/CLI/index.html
8ba9b85d29b0-0
Job Queue Overview The Job Queue executes automated tasks in Sugar through a scheduler, which integrates with external UNIX systems and Windows systems to run jobs that are scheduled through those systems. Jobs are the individual runs of the specified function from a scheduler.  The Job Queue is composed of the following parts: SugarJobQueue : Implements the queue functionality. The queue contains the various jobs. SchedulersJob : A single instance of a job. This represents a single executable task and is held in the SugarJobQueue. Scheduler : This is a periodically occurring job. SugarCronJobs : The cron process that uses SugarJobQueue to run jobs. It runs periodically and does not support parallel execution. Stages Schedule Stage
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/index.html
8ba9b85d29b0-1
Stages Schedule Stage On the scheduling stage (checkPendingJobs in Scheduler class), the queue checks if any schedules are qualified to run at this time and do not have job instance already in the queue. If such schedules exist, a job instance will immediately be created for each. Execution Stage The SQL queue table is checked for any jobs in the "Pending" status. These will be set to "Running"' and then executed in accordance to its target and settings. Cleanup Stage The queue is checked for jobs that are in the "Running" state longer than the defined timeout. Such jobs are considered "Failed" jobs (they may be re-queued if their definition includes re-queuing on failure).
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/index.html
8ba9b85d29b0-2
TopicsSchedulersSugar provides a Scheduler service that can execute predefined functions asynchronously on a periodic basis. The Scheduler integrates with external UNIX systems and Windows systems to run jobs that are scheduled through those systems. The typical configuration is to have a UNIX cron job or a Windows scheduled job execute the Sugar Scheduler service every couple of minutes. The Scheduler service checks the list of Schedulers defined in the Scheduler Admin screen and executes any that are currently due.Scheduler JobsJobs are the individual runs of the specified function from a scheduler. This article will outline the various parts of a Scheduler Job. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/index.html
2fc9630da084-0
Scheduler Jobs Overview Jobs are the individual runs of the specified function from a scheduler. This article will outline the various parts of a Scheduler Job. Properties name : Name of the job scheduler_id : ID of the scheduler that created the job. This may be empty as schedulers are not required to create jobs execute_time : Time when job is ready to be executed status : Status of the job resolution : Notes whether or not the job was successful message : Contains messages produced by the job, including errors target : Function or URL called by the job data : Data attached to the job requeue : Boolean to determine whether the job will be replaced in the queue upon failure retry_count : Determines how many times the system will retry the job before failure failure_count : The number f times the job has failed
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/index.html
2fc9630da084-1
failure_count : The number f times the job has failed job_delay : The delay (in seconds) between each job run assigned_user_id : User ID of which the job will be executed as client : The name of the client owning the job percent_complete : For postponed jobs, this can be used to determine how much of the job has been completed Creating a Job To create job, you must first create an instance of SchedulesJobs class and use submitJob in SugarJobQueue. An example is shown below: <?php $jq = new SugarJobQueue(); $job = new SchedulersJob(); $job->name = "My Job"; $job->target = "function::myjob"; $jobid = $jq->submitJob($job); echo "Created job $jobid!"; Job Targets
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/index.html
2fc9630da084-2
echo "Created job $jobid!"; Job Targets Job target contains two components, type and name, separated by "::". Type can be: function : Name or static method name (using :: syntax). This function will be passed the job object as the first parameter and if data is not empty, it will be passed as the second parameter. url : External URL to call when running the job Running the Job The job is run via the runJob() function in SchedulersJob. This function will return a boolean success value according to the value returned by the target function. For URL targets, the HTTP error code being less than 400 will return success. If the function updated the job status from 'running', the return value of a function is ignored. Currently, the postponing of a URL job is not supported. Job status Jobs can be in following statuses:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/index.html
2fc9630da084-3
Job status Jobs can be in following statuses: queued : The job is waiting in the queue to be executed running : The job is currently being executed done : The job has executed and completed Job Resolution Job resolution is set when the job is finished and can be: queued : The job is still not finished success : The job has completed successfully failure : The job has failed partial : The job is partially done but needs to be completed Job Logic Hooks The scheduler jobs module has two additional logic hooks that can be used to monitor jobs. The additional hooks that can be used are shown below: job_failure_retry : Executed when a job fails but will be retried job_failure : Executed when the job fails for the final time You can find more information on these hooks in the Job Queue Hooks section.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/index.html
2fc9630da084-4
You can find more information on these hooks in the Job Queue Hooks section. TopicsCreating Custom JobsHow to create and execute your own custom jobs.Queuing Logic Hook ActionsThis example will demonstrate how to pass tasks to the job queue. This enables you to send longer running jobs such as sending emails, calling web services, or doing other resource intensive jobs to be handled asynchronously by the cron in the background. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/index.html
aac55b55e15c-0
Queuing Logic Hook Actions Overview This example will demonstrate how to pass tasks to the job queue. This enables you to send longer running jobs such as sending emails, calling web services, or doing other resource intensive jobs to be handled asynchronously by the cron in the background. Example This example will queue an email to be sent out by the cron when an account record is saved. First, we will create a before_save logic hook on accounts. ./custom/modules/Accounts/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_save'][] = Array(); $hook_array['before_save'][] = Array( 1, 'Queue Job Example', 'custom/modules/Accounts/Accounts_Save.php',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/Queuing_Logic_Hook_Actions/index.html
aac55b55e15c-1
'custom/modules/Accounts/Accounts_Save.php', 'Accounts_Save', 'QueueJob' ); ?> In our logic hook, we will create a new SchedulersJob and submit it to the SugarJobQueue targeting our custom AccountAlertJob that we will create next. ./custom/modules/Accounts/Accounts_Save.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); require_once 'include/SugarQueue/SugarJobQueue.php'; class Accounts_Save { function QueueJob(&$bean, $event, $arguments) { //create the new job $job = new SchedulersJob(); //job name
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/Queuing_Logic_Hook_Actions/index.html
aac55b55e15c-2
$job = new SchedulersJob(); //job name $job->name = "Account Alert Job - {$bean->name}"; //data we are passing to the job $job->data = $bean->id; //function to call $job->target = "function::AccountAlertJob"; global $current_user; //set the user the job runs as $job->assigned_user_id = $current_user->id; //push into the queue to run $jq = new SugarJobQueue(); $jobid = $jq->submitJob($job); } } ?>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/Queuing_Logic_Hook_Actions/index.html
aac55b55e15c-3
} } ?> Next, we will need to define the Job. This will be done by creating a new function to execute our code. We will put this file in the ./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/ directory with the name AccountAlertJob.php. ./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/AccountAlertJob.php <?php function AccountAlertJob($job) { if (!empty($job->data)) { $bean = BeanFactory::getBean('Accounts', $job->data); $emailObj = new Email(); $defaults = $emailObj->getSystemDefaultEmail(); $mail = new SugarPHPMailer(); $mail->setMailerForSystem();
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/Queuing_Logic_Hook_Actions/index.html
aac55b55e15c-4
$mail->setMailerForSystem(); $mail->From = $defaults['email']; $mail->FromName = $defaults['name']; $mail->Subject = from_html($bean->name); $mail->Body = from_html("Email alert that '{$bean->name}' was saved"); $mail->prepForOutbound(); $mail->AddAddress('[email protected]'); if($mail->Send()) { //return true for completed return true; } } return false; }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/Queuing_Logic_Hook_Actions/index.html
aac55b55e15c-5
return true; } } return false; } Finally, navigate to Admin / Repair / Quick Repair and Rebuild. The system will then generate the file ./custom/modules/Schedulers/Ext/ScheduledTasks/scheduledtasks.ext.php containing our new function. We are now able to queue and run the scheduler job from a logic hook. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/Queuing_Logic_Hook_Actions/index.html
514798637069-0
Creating Custom Jobs Overview How to create and execute your own custom jobs. How it Works As of 6.3.0, custom job functions can be created using the extension framework. The function for the job will be defined in ./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/. Files in this directory are compiled into ./custom/modules/Schedulers/Ext/ScheduledTasks/scheduledtasks.ext.php and then included for use in ./modules/Schedulers/_AddJobsHere.php. Creating the Job Use the section below to introduce the technology in relation to the product and describe its benefits. This first step is to create your jobs custom key. For this example we will be using 'custom_job' as our job key.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/Creating_Custom_Jobs/index.html
514798637069-1
./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/custom_job.php <?php //add the job key to the list of job strings array_push($job_strings, 'custom_job'); function custom_job() { //custom job code //return true for completed return true; } Next, we will need to define our jobs label string: ./custom/Extension/modules/Schedulers/Ext/Language/en_us.custom_job.php <?php $mod_strings['LBL_CUSTOM_JOB'] = 'Custom Job'; Finally, We will need to navigate to: Admin / Repair / Quick Repair and Rebuild Once a Quick Repair and Rebuild has been run, the new job will be available for use when creating new schedulers in:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/Creating_Custom_Jobs/index.html
514798637069-2
Admin / Scheduler Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Jobs/Creating_Custom_Jobs/index.html
6e50aab35040-0
Schedulers Overview Sugar provides a Scheduler service that can execute predefined functions asynchronously on a periodic basis. The Scheduler integrates with external UNIX systems and Windows systems to run jobs that are scheduled through those systems. The typical configuration is to have a UNIX cron job or a Windows scheduled job execute the Sugar Scheduler service every couple of minutes. The Scheduler service checks the list of Schedulers defined in the Scheduler Admin screen and executes any that are currently due. A series of schedulers are defined by default with every Sugar installation. For detailed information on these stock schedulers, please refer to the Schedulers documentation. Config Settings cron.max_cron_jobs - Determines the maximum number of jobs executed per cron run cron.max_cron_runtime - Determines the maximum amount of time a job can run before forcing a failure
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Schedulers/index.html
6e50aab35040-1
cron.min_cron_interval - Specified the minimum amount of time between cron runs Considerations Schedulers execute the next time the cron runs after the interval of time has passed, which may not be at the exact time specified on the scheduler. If you see the message "Job runs too frequently, throttled to protect the system" in the Sugar log, the cron is running too frequently. If you would prefer the cron to run more frequently, set the cron.min_cron_interval setting to 0 and disable throttling completely. TopicsCreating Custom SchedulersIn addition to the default schedulers that are packaged with Sugar, developers can create custom scheduler jobs. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Schedulers/index.html
37086abde458-0
Creating Custom Schedulers Overview In addition to the default schedulers that are packaged with Sugar, developers can create custom scheduler jobs. Defining the Job Label The first step to create a custom scheduler is creating a label extension file. This will add the display text for the scheduler job when creating a new scheduler in Admin > Scheduler. The file path of our file will be in the format of ./custom/Extension/modules/Schedulers/Ext/Language/<language key>.<name>.php. For our example, name the file en_us.custom_job.php. ./custom/Extension/modules/Schedulers/Ext/Language/en_us.custom_job.php <?php $mod_strings['LBL_CUSTOM_JOB'] = 'Custom Job';
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Schedulers/Creating_Custom_Schedulers/index.html
37086abde458-1
Defining the Job Function Next, define the custom job's function using the extension framework. The file path of the file will be in the format of ./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/<function_name>.php. For this example, name the file custom_job.php. Prior to 6.3.x, job functions were added by creating the file ./custom/modules/Schedulers/_AddJobsHere.php. This method of creating functions is still compatible but is not recommended from a best practices standpoint. ./custom/Extension/modules/Schedulers/Ext/ScheduledTasks/custom_job.php <?php array_push($job_strings, 'custom_job'); function custom_job() { //logic here //return true for completed
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Schedulers/Creating_Custom_Schedulers/index.html
37086abde458-2
{ //logic here //return true for completed return true; } Using the New Job Once the files are in place, navigate to Admin > Repair > Quick Repair and Rebuild. This will rebuild the extension directories with our additions. Next, navigate to Admin > Scheduler > Create Scheduler. In the Jobs dropdown, there will be a new custom job in the list. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Job_Queue/Schedulers/Creating_Custom_Schedulers/index.html
b69096dd30ca-0
Shortcuts Overview Shortcuts is a framework to add shortcut keys to the application. When shortcut keys are registered, they are registered to a particular shortcut session. Shortcut sessions group shortcut keys, and they can be activated, deactivated, saved, and restored. Global shortcut keys can be registered, but they are not tied to a particular shortcut session. They are rather applied everywhere in the application and can only be applied once. The Shortcut framework is implemented on top of Mousetrap library. Shortcut Sessions In order to register a shortcut in Sugar, a shortcut session must first be created by adding ShortcutSession plugin to the top-level layout JavaScript controller. plugins: ['ShortcutSession'] Then, the top-level layout needs to list which shortcuts are allowed in the shortcut session. Shortcuts can be listed in the top-level layout JavaScript controller :
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
b69096dd30ca-1
./custom/clients/layout/my-layout/my-layout.js shortcuts: [ 'Sidebar:Toggle', 'Record:Save', 'Record:Cancel', 'Record:Action:More' ] Shortcuts can also be listed in the metadata : ./custom/clients/layout/my-layout/my-layout.php 'shortcuts' => array( 'Sidebar:Toggle', 'Record:Save', 'Record:Cancel', 'Record:Action:More' ), Register Once a shortcut session is created, shortcut keys can be registered by adding the following in your JavaScript code : app.shortcuts.register('<unique shortcut ID>', '<shortcut keys>', <callback function>, <current component>, <call on focus?>);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
b69096dd30ca-2
Since shortcut keys should only be registered once in your component, they should be registered inside initialize() or someplace where re-rendering the component would not register more than once. Shortcut IDs Shortcut IDs should be unique across the application. They should be namespaced by convention, for example Record:Next, Sidebar:Toggle, List:Edit. If the namespace starts with Global:, it assumes that the shortcut is global. Global shortcuts Global shortcuts are shortcut keys that are applied once and are available everywhere in the application. app.shortcuts.register(app.shortcuts.GLOBAL + 'Footer:Help', '?', function() {}, this, false); Shortcut Keys There are only certain keys that are supported under the Shortcut framework. The following keyboard keys can be used :  All alphanumeric characters and symbols shift, ctrl, alt, option, meta, command
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
b69096dd30ca-3
shift, ctrl, alt, option, meta, command backspace, tab, enter, return, capslock, esc, escape, space, pageup, pagedown, end, home, ins, del left, up, right, down Additional Features In addition to standard keys, the Shortcut framework also supports some additional features : Key combinations : 'ctrl+s' Multiple keys : ['ctrl+a', 'command+a'] Key sequences : 'f a' Input Focus The fifth parameter in the register method specifies whether or not the shortcut key should be fired when the user is focused in an input field. It is false by default. app.shortcuts.register('Record:Save', ['ctrl+s','command+s'], function() {}, this, true); Limitations Shortcut keys do not work on side panels, like dashboards and previews.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
b69096dd30ca-4
Limitations Shortcut keys do not work on side panels, like dashboards and previews. Shortcuts Help Anytime a new shortcut is created, a help text should be provided in ./clients/base/layouts/shortcuts/shortcuts.php with a shortcut ID and a language string. 'List:Favorite' => 'LBL_SHORTCUT_FAVORITE_RECORD', Shortcuts help is displayed when Shortcuts button is clicked. Advanced Features Enable/disable dynamically Shortcuts feature can be enabled and disabled dynamically via code by calling app.shortcuts.enable() and app.shortcuts.disable(). Dynamically saving, creating new, and restoring sessions A new shortcut session is created when a user visits a top-level layout with ShortcutSession plugin. A new session can be created dynamically:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
b69096dd30ca-5
app.shortcuts.createSession(<array of shorcut IDs>, <component>); But before creating a new session, the current session should be saved first. app.shortcuts.saveSession(); app.shortcuts.createSession(<array of shorcut IDs>, <component>); Once a new session is created, shortcut keys can be registered to it. When the need for the session is done, the previous shortcut session can be restored. app.shortcuts.restoreSession(); Example The following example will be to add some custom shortcuts onto a custom layout. For more information on how to create a custom layout, please refer to the Creating Layouts documentation. First, on our custom JavaScript controller for our layout, we must enable the ShortcutSession plugin as well as list the shortcuts we will be enabling :
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
b69096dd30ca-6
./custom/clients/base/layouts/my-layout/my-layout.js ({ plugins: ['ShortcutSession'], shortcuts: [ 'Global:MyLayout:MyCallback', ], }) Next, on the custom view being rendered on our layout, we will register the new shortcuts as well as define a callback method :  ./custom/clients/base/views/my-view/my-view.js ... initialize: function(options){ this._super('initialize', [options]); // call myCallback method when command + a is pressed app.shortcuts.register(app.shortcuts.GLOBAL + 'MyLayout:MyCallback', 'command+a', this.myCallback, this, false); app.shortcuts.saveSession(); app.shortcuts.createSession([
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
b69096dd30ca-7
app.shortcuts.saveSession(); app.shortcuts.createSession([ 'MyLayout:InlineCall' ], this); // call inline code when control + m or command + m is pressed app.shortcuts.register('MyLayout:InlineCall', ['ctrl+m','command+m'], function() { console.log("Ctrl or Command m has been pressed"); }, this, false); }, myCallback: function(){ console.log("MyCallback called from Command a"); }, ... The last step will be to create a new label for our shortcut help text and register the help so it displays when "Shortcuts" is click in the footer of the page : ./custom/Extension/application/Ext/Language/en_us.LBL_MYLAYOUT_SHORTCUT_HELP.php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
b69096dd30ca-8
<?php $app_strings['LBL_MYLAYOUT_MYCALLBACK_HELP'] = "Activates my Callback Method"; $app_strings['LBL_MYLAYOUT_MYINLINECALL_HELP'] = "Activates Inline Code"; ./custom/Extension/application/Ext/clients/base/layouts/shortcuts/shortcuts.php <?php $viewdefs['base']['layout']['shortcuts']['help']['Global:MyLayout:MyCallback'] = 'LBL_MYLAYOUT_MYCALLBACK_HELP'; $viewdefs['base']['layout']['shortcuts']['help']['MyLayout:InlineCall'] = 'LBL_MYLAYOUT_MYINLINECALL_HELP';
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
b69096dd30ca-9
Navigate to Admin > Repair > Quick Repair and Rebuild. The system will then rebuild the extensions and add the new shortcut to the custom layout. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
2b3f29e6ea7e-0
Duplicate Check Overview The duplicate-check framework provides the capability to alter how the system searches for duplicate records in the database when creating records. For information on duplicate checking during imports, please refer to the index documentation. Default Strategy The default duplicate-check strategy, located in ./data/duplicatecheck/FilterDuplicateCheck.php, is referred to as FilterDuplicateCheck. This strategy utilizes the Filter API and a defined filter in the vardefs of the module to search for duplicates and rank them based on matching data. Custom Filter To alter a defined filter for a stock a module, you only need to update the Vardefs using the Extensions framework. If you are working with a custom module, you can modify the vardefs in ./modules/<module>/vardefs.php directly. The FilterDuplicateCheck Strategy accepts two properties in its metadata:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-1
Name Type Description filter_template array An array containing the Filter Definition for which fields to search for duplicates on. Please consult the Filter API for further information on the filter syntax ranking_fields array A list of arrays with the following properties. The order in which you list the fields for ranking will determine the ranking score. The first ranks higher, than those after it. in_field_name: Name of field in vardefs dupe_field_name: Name of field returned by filter Example The following example will demonstrate how to manipulate the stock Accounts duplicate check to not filter on the shipping address city. The default Account duplicate_check defintion, located in ./modules/Accounts/vardefs.php, is shown below. ... 'duplicate_check' => array( 'enabled' => true,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-2
'duplicate_check' => array( 'enabled' => true, 'FilterDuplicateCheck' => array( 'filter_template' => array( array( '$or' => array( array('name' => array('$equals' => '$name')), array('duns_num' => array('$equals' => '$duns_num')), array( '$and' => array( array('name' => array('$starts' => '$name')), array( '$or' => array( array('billing_address_city' => array('$starts' => '$billing_address_city')),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-3
array('shipping_address_city' => array('$starts' => '$shipping_address_city')), ) ), ) ), ) ), ), 'ranking_fields' => array( array('in_field_name' => 'name', 'dupe_field_name' => 'name'), array('in_field_name' => 'billing_address_city', 'dupe_field_name' => 'billing_address_city'), array('in_field_name' => 'shipping_address_city', 'dupe_field_name' => 'shipping_address_city'), ) ) ), ...
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-4
) ) ), ...  To add or remove fields from the check, you will need to manipulate $dictionary['<module>']['duplicate_check']['FilterDuplicateCheck']['filter_template'] and   $dictionary['<module>']['duplicate_check']['FilterDuplicateCheck']['ranking_fields'] . For our example, we will simply remove the references to shipping_address_city.  It is important to familiarize yourself with filter operators before making any changes. ./custom/Extension/modules/Accounts/Ext/Vardefs/newFilterDuplicateCheck.php <?php $dictionary['Account']['duplicate_check']['FilterDuplicateCheck'] = array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-5
'filter_template' => array( array( '$or' => array( array('name' => array('$equals' => '$name')), array('duns_num' => array('$equals' => '$duns_num')), array( '$and' => array( array('name' => array('$starts' => '$name')), array( '$or' => array( array('billing_address_city' => array('$starts' => '$billing_address_city')), ) ), ) ), ) ), ), 'ranking_fields' => array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-6
) ), ), 'ranking_fields' => array( array('in_field_name' => 'name', 'dupe_field_name' => 'name'), array('in_field_name' => 'billing_address_city', 'dupe_field_name' => 'billing_address_city'), ) ); Finally, navigate to Admin > Repair > Quick Repair and Rebuild. The system will then enable the custom duplicate-check class. If you want to disable the duplicate check entirely, you can set $dictionary['<module>']['duplicate_check']['enabled'] to false in your vardefs and run a Quick Repair and Rebuild. $dictionary['Account']['duplicate_check']['enabled'] = false; Custom Strategies
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-7
Custom Strategies Custom duplicate-check class files are stored under ./custom/data/duplicatecheck/. The files in this directory can be enabled on a module's duplicate_check property located in ./custom/Extension/modules/<module>/Ext/Vardefs/. Only one duplicate-check class can be enabled on a module at a given time. Duplicate Check Class To create a custom duplicate-check strategy, you need to create a custom duplicate-check class that extends the base DuplicateCheckStrategy, ./data/duplicatecheck/DuplicateCheckStrategy.php. To work, this custom class requires the implementation of two methods: Method Name Description setMetadata Sets up properties for duplicate-check logic based on the passed-in metadata findDuplicates Finds possible duplicate records for a given set of field data Example
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-8
findDuplicates Finds possible duplicate records for a given set of field data Example The following example will create a new duplicate-check class called "OneFieldDuplicateCheck" that will query the database based on the configured field for records that contain data similar to that one field: ./custom/data/duplicatecheck/OneFieldDuplicateCheck.php <?php if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class OneFieldDuplicateCheck extends DuplicateCheckStrategy { protected $field; public function setMetadata($metadata) { if (isset($metadata['field'])) { $this->field = $metadata['field']; } } public function findDuplicates() { if (empty($this->field)){
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-9
{ if (empty($this->field)){ return null; } $Query = new SugarQuery(); $Query->from($this->bean); $Query->where()->ends($this->field,$this->bean->{$this->field}); $Query->limit(10); //Filter out the same Bean during Edits if (!empty($this->bean->id)) { $Query->where()->notEquals('id',$this->bean->id); } $results = $Query->execute(); return array( 'records' => $results ); } } Vardef Settings The duplicate-check vardef settings are configured on each module and can be altered using the Extension framework. Name Type Description enabled boolean
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-10
Name Type Description enabled boolean Whether or not duplicate-check framework is enabled on the module <class_name> array The class name that will provide duplicate checking, set to an array of metadata that gets passed to the duplicate-check class  If you want to enable the OneFieldDuplicateCheck strategy (shown above) for the Accounts module, you must create the following file: ./custom/Extension/modules/Accounts/Ext/Vardefs/newDuplicateCheck.php <?php $dictionary['Account']['duplicate_check'] = array( 'enabled' => true, 'OneFieldDuplicateCheck' => array( 'field' => 'name' ) ); Finally, navigate to Admin > Repair > Quick Repair and Rebuild. The system will then enable the custom duplicate-check class.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
2b3f29e6ea7e-11
Programmatic Usage You can also use the duplicate-check framework in code such as in a logic hook or a scheduler. The following example shows how to use the module's defined duplicate-check strategy when utilizing a bean object by simply calling the findDuplicates method on the bean object: $account = BeanFactory::newBean('Accounts'); $account->name = 'Test'; $duplicates = $account->findDuplicates(); if (count($duplicates['records'])>0){ $GLOBALS['log']->fatal("Duplicate records found for Account"); } Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Duplicate_Check/index.html
6ae2b3a1bcb8-0
DateTime Overview The SugarDateTime class, located in, ./include/SugarDateTime.php, extends PHP's built in DateTime class and can be used to perform common operations on date and time values.  Setting With existing SugarDateTime objects, it is recommended to clone the object before modifying or performing operations on it. $new_datetime = clone $datetime; Another option is to instantiate a new SugarDateTime object. // defaults to now $due_date_time = new SugarDateTime(); $due_date_time->setDate($dueYear, $dueMonth, $dueDay); $due_date_time->setTime($dueHour, $dueMin); $due_date_time->setTimezone($dueTZ);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-1
$due_date_time->setTimezone($dueTZ); Note : When creating a new SugarDateTime object, the date and time will default to the current date and time in the timezone configured in PHP. SugarDateTime Objects can also be modified by passing in common English textual date/time strings to manipulate the value. $due_date = clone $date; $end_of_the_month->modify("last day of this month"); $end_of_next_month->modify("last day of next month"); $thirty_days_later->modify("+30 days"); Formatting When formatting SugarDateTime objects into a string for display or logging purposes, there are a few options you can utilize through the formatDateTime() method. Return the date/time formatted for the database:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-2
Return the date/time formatted for the database: $db_datetime_string = formatDateTime("datetime", "db"); Return the date/time formatted using a user's preference: global $current_user; $user_datetime_string = formatDateTime("datetime", "user", $current_user); Return the date/time formatted following ISO-8601 standards: $iso_datetime_string = formatDateTime("datetime", "iso"); There are times when it is needed to return only certain parts of a date or time. The format() method accepts a string parameter to define what parts or information about the date/time should be returned.  // 28 Dec 2016 echo $due_date_time->format("j M Y"); // 2016-12-28 19:01:09 echo $due_date_time->asDb();
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-3
echo $due_date_time->asDb(); // The date/time 2016-12-28T11:01:09-08:00 is set in the timezone of America/Los_Angeles echo "The date/time " . $due_date_time->format("c") . " is set in the timezone of " . $due_date_time->format("e"); // The time when this date/time object was created is 11:01:09 AM -0800 echo "The time when this date/time object was created is " . $due_date_time->format("H:i:s A O"); // There are 31 days in the month of December echo "There are " . $due_date_time->format("t") . " days in the month of " . $due_date_time->format("F");
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-4
// There are 366 days in the year of 2016 echo "There are " . $due_date_time->__get("days_in_year") . " days in the year of " . $due_date_time->format("Y"); // Between Wed, 28 Dec 2016 11:01:09 -0800 and the end of the year, there are 4 days. echo "Between " . $due_date_time . " and the end of the year, there are " . ($due_date_time->__get("days_in_year") - $due_date_time->format("z")) . " days.";  For more information on the available options, please refer to http://php.net/manual/en/function.date.php  TimeDate Class
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-5
TimeDate Class The TimeDate class, located in ./include/TimeDate.php, utilizes the SugarDateTime class to provide an extended toolset of methods for date/time usage. Setting With existing TimeDate objects, it is recommended to clone the object before modifying or performing operations on it. $new_timedate = clone $timedate; Another option is to instantiate a new TimeDate object. // current time in UTC $timedate = new TimeDate(); $now_utcTZ = $timedate->getNow(); // current time in user's timezone $timedate = new TimeDate($current_user); $now_userTZ = $timedate->getNow(true);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-6
$now_userTZ = $timedate->getNow(true); Note : When creating a new TimeDate object, the date and time will default to the current date and time in the UTC timezone unless a user object is passed in.  Formatting TimeDate objects can return the Date/Time in either a string format or in a SugarDateTime object. The TimeDate object has many formatting options; some of the most common ones are : getNow Get the current date/time as a SugarDateTime object  fromUser Get SugarDateTime object from user's date/time string asUser Format DateTime object as user's date/time string fromDb Get SugarDateTime object from a DB date/time string fromString Create a SugarDateTime object from a string
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-7
fromString Create a SugarDateTime object from a string get_db_date_time_format Gets the current database date and time format to_display_date_time Format a string as user's display date/time getNow returns SugarDateTime object Parameters Name Data Type Default Description $userTz bool false Whether to use the user's timezone or not. False will use UTC Returns a SugarDateTime object set to the current date/time. If there is a user object associate to the TimeDate object, passing true to the $userTz parameter will return the object in user's timezone. If no user is associated or false is passed, the timezone returned will be in UTC. Example $timedate = new TimeDate($current_user);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-8
Example $timedate = new TimeDate($current_user); // returns current date/time in UTC $now_utcTZ = $timedate->getNow(); // returns current date/time in the user's timezone $now_userTZ = $timedate->getNow(true); fromUser returns SugarDateTime object Parameters Name Data Type Default Description $date string n/a Date/Time string to convert to an object $user User null User to utilize formatting and timezone info from Returns a SugarDateTime object converted from the passed in string. If there is a user object passed in as a parameter will return the object in user's timezone. If no user is passed in, the timezone returned will be in UTC. Example
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-9
Example $date = "2016-12-28 13:09"; $timedate = new TimeDate(); $datetime = $timedate->fromUser($date, $current_user); asUser returns string Parameters Name Data Type Default Description $date string n/a Date/Time string to convert to an object $user User null User to utilize formatting and timezone info from Returns a string of the date and time formatted based on the user's profile settings. If there is a user object passed in as a parameter it will return the object in user's timezone. If no user is passed in, the timezone returned will be in UTC. Example $datetime = new datetime("2016-12-28 13:09"); $timedate = new TimeDate();
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-10
$timedate = new TimeDate(); $formattedDate = $timedate->asUser($datetime, $current_user); fromDb returns SugarDateTime Parameters Name Data Type Default Description $date string n/a Date/Time string in database format to convert to an object Returns a SugarDateTime object converted from the passed in database formatted string. Note : If the string does not match the database format exactly, this function will return boolean false. Example // Y-m-d H:i:s $db_datetime = "2016-12-28 13:09:01"; $timedate = new TimeDate(); $datetime = $timedate->fromDb($db_datetime); // returns bool(false) $wrong_datetime = "2016-12-28 13:09";
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-11
$wrong_datetime = "2016-12-28 13:09"; $timedate = new TimeDate(); $datetime = $timedate->fromDb($timedate); fromString returns SugarDateTime Parameters Name Data Type Default Description $date string n/a Date/Time string to convert to an object $user User null User to utilize timezone info from Returns a SugarDateTime object converted from the passed in database formatted string. If there is a user object passed in as a parameter it will return the object in user's timezone. If no user is passed in, the timezone returned will be in UTC. Example $datetime_str = "December 28th 2016 13:09"; $timedate = new TimeDate();
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-12
$timedate = new TimeDate(); $datetime = $timedate->fromString($datetime_str); get_db_date_time_format returns string Parameters N/a Returns a string of the current database date and time format settings.  Note : For just the date format use get_db_date_format() and for just the time format use get_db_time_format(). Example $timedate = new TimeDate(); // Y-m-d H:i:s $db_format = $timedate->get_db_date_time_format(); to_display_date_time returns string Parameters Name Data Type Default Description $date string n/a Date/Time string in database format $meridiem boolean
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-13
n/a Date/Time string in database format $meridiem boolean true Deprecated -- Remains for backwards compatibility only $convert_tz boolean true Convert to user's timezone $user User null User to utilize formatting and timezone info from Returns a string of the date and time formatted based on the user's profile settings. If no user is passed in, the current user's default will be used. If $convert_tz is true the string returned will be in the passed in user's timezone. If no user is passed in, the timezone returned will be in UTC. Note : If the string does not match the database format exactly, this function will return boolean false. Example $datetime_str = "2016-12-28 13:09:01"; // 12-28-2016 07:09
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-14
// 12-28-2016 07:09 $timedate = new TimeDate(); $datetime = $timedate->to_display_date_time($datetime_str); // 2016-12-28 13:09 $timedate = new TimeDate(); $datetime = $timedate->to_display_date_time($datetime_str, true, false, $diff_user); Parsing In addition to formatting, TimeDate objects can also return Date/Time values based on special parameters. The TimeDate object has many date parsing options; some of the most common ones are : parseDateRange Gets the start and end date/time from a range keyword  parseDateRange returns array Parameters Name Data Type Default Description $range string n/a
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-15
Parameters Name Data Type Default Description $range string n/a String from a predetermined list of available ranges $user User null User to utilize formatting and timezone info from $adjustForTimezone boolean true Convert to user's timezone Returns an array of SugarDateTime objects containing the start and Date/Time values calculated based on the entered parameter. If no user is passed in, the current user's default will be used. If $adjustForTimezone is true the string returned will be in the passed in user's timezone. If NULL is passed in as the user, the timezone returned will be in UTC. The available values for $range are : Range String Description yesterday Yesterday's start and end date/time today Today's start and end date/time tomorrow
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-16
today Today's start and end date/time tomorrow Tomorrows's start and end date/time last_7_days Start and end date/time of the last seven days next_7_days Start and end date/time of the next seven days last_30_days Start and end date/time of the last thirty days next_30_days Start and end date/time of the next thirty days next_month Start and end date/time of next month last_month Start and end date/time of last month this_month Start and end date/time of the current month last_year Start and end date/time of last year this_year Start and end date/time of the current year next_year Start and end date/time of next year Example $timedate = new TimeDate($current_user);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
6ae2b3a1bcb8-17
Example $timedate = new TimeDate($current_user); // returns today's start and end date/time in UTC $today_utcTZ = $timedate->parseDateRange("today", NULL, false); // returns today's start and end date/time in the user's timezone $today_userTZ = $timedate->parseDateRange("today", $current_user, true); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/DateTime/index.html
86a373ee6d6f-0
Performance Tuning The following sections detail ways to enhance the performance of your Sugar instance.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/index.html
86a373ee6d6f-1
TopicsSugar PerformancePerformance recommendations when working with Sugar.PHP ProfilingAs of the 6.6.2 release, Sugar introduced the ability to profile via XHProf, which is an easy-to-use, hierarchical profiler for PHP. This allows developers to better manage and understand customer performance issues introduced by their customizations. This tool enables quick and accurate identification of the sources of performance sinks within the code by generating profiling logs. Profiling gives you the ability to see the call stack for the entire page load with timing details around function and method calls as well as statistics on call frequency.Integrating Sugar With New Relic APM for Performance ManagementSugar® 7 includes support for New Relic APM™, a third-party Application Performance Management (APM) tool that can facilitate deep insight into your Sugar instance in order to troubleshoot sluggish response times. This article explains how to set up and use New Relic in conjunction with Sugar for powerful performance management
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/index.html
86a373ee6d6f-2
This article explains how to set up and use New Relic in conjunction with Sugar for powerful performance management capabilities.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/index.html
86a373ee6d6f-3
Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/index.html
b04f8c128d53-0
PHP Profiling Overview As of the 6.6.2 release, Sugar introduced the ability to profile via XHProf, which is an easy-to-use, hierarchical profiler for PHP. This allows developers to better manage and understand customer performance issues introduced by their customizations. This tool enables quick and accurate identification of the sources of performance sinks within the code by generating profiling logs. Profiling gives you the ability to see the call stack for the entire page load with timing details around function and method calls as well as statistics on call frequency. Assuming XHProf is installed and enabled in your PHP configuration (which you can learn how to do in the PHP Manual), you can enable profiling in Sugar by adding the following parameters to the ./config_override.php file: $sugar_config['xhprof_config']['enable'] = true;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/PHP_Profiling/index.html
b04f8c128d53-1
$sugar_config['xhprof_config']['enable'] = true; $sugar_config['xhprof_config']['log_to'] = '{instance server path}/cache/xhprof'; // x where x is a number and 1/x requests are profiled. So to sample all requests set it to 1 $sugar_config['xhprof_config']['sample_rate'] = 1; // array of function names to ignore from the profile (pass into xhprof_enable) $sugar_config['xhprof_config']['ignored_functions'] = array(); // flags for xhprof $sugar_config['xhprof_config']['flags'] = XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/PHP_Profiling/index.html
b04f8c128d53-2
Please note that with the above 'log_to' parameter, you would need to create the  ./cache/xhprof/ directory in your instance directory with proper permissions and ownership for the Apache user. You can also opt to leave the  xhprof_config.log_to parameter empty and set the logging path via the  xhprof.output_dir parameter in the  php.ini file. Once the above parameters are set, XHProf profiling will log all output to the indicated directory and allow you to research any performance related issues encountered in the process of developing and maintaining the application. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/PHP_Profiling/index.html
d5b44b3248ee-0
Sugar Performance Overview As your company uses Sugar over time, the size of your database will naturally grow and, without the proper maintenance, performance will inevitably begin to degrade. The purpose of this article is to review some of the most common recommendations for increasing the performance in Sugar to help increase the system's efficiency for your users. Note: This guide is intended for on-site installations. Customers hosted on Sugar's cloud service should file a support case for any performance issues. General Settings in Sugar The following recommendations can be modified in the Sugar admin interface
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Sugar_Performance/index.html
d5b44b3248ee-1
General Settings in Sugar The following recommendations can be modified in the Sugar admin interface Do Not Set Listview and Subpanel Items Per Page to Excessive Settings. Under Admin > System Settings, there are two settings 'Listview items per page' and 'Subpanel items per page'. The defaults for these settings are 20 and 10 respectively. When increasing these values, it should be expected that general system wide performance will be impacted. We generally recommend keeping listview settings to 100 or less and subpanel settings to be set to 10 or less to keep system performance optimal. Make sure 'Developer Mode' is disabled under Admin > System Settings. This setting should never be enabled in a production environment as it causes cached files to be rebuilt on every page load.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Sugar_Performance/index.html
d5b44b3248ee-2
Set the 'Log Level' to 'Fatal' and 'Maximum log size' to '10M' under Admin > System Settings. The log level should only be set to more verbose levels when troubleshooting the application as it will cause a performance degradation as user activity increases. Ensure the scheduled job, 'Prune Database on the 1st of Month', is set to 'Active'. This will go through your database and delete any records that have been deleted by your users. Sugar only soft deletes records when a user deletes a record and over time, this will cause performance degradation if these records are not removed from the database. Make sure 'Tracker Performance' and 'Tracker Queries' are disabled under Admin > Tracker. These settings are intended to help diagnose performance issues and should never be left enabled in a production environment.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Sugar_Performance/index.html
d5b44b3248ee-3
Ensure large scheduler jobs are running at slower intervals under Admin > Scheduler. Jobs such as 'Check Inbound Mailboxes' can decrease overall performance if they are running every minute and polling a lot of data. It is important to set these jobs to every 5 or 10 minutes to help offset the performance impacts for your users. Sugar Performance Settings General Settings Disable client IP verification : Eliminates the system checking to see if the user is accessing Sugar from the IP address of their last page load. $sugar_config['verify_client_ip'] = false; BWC Modules For modules running in Backward Compatibility mode, the following settings can be used to speed up performance: Drop the absolute totals from listviews : Eliminates performing expensive count queries on the database when populating listviews and subpanels. $sugar_config['disable_count_query'] = true;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Sugar_Performance/index.html
d5b44b3248ee-4
$sugar_config['disable_count_query'] = true; Disable automatic searches on listviews : Forces a user to perform a search when they access a listview rather than loading the results from their last search. $sugar_config['save_query'] = 'populate_only';  Hide all subpanels :  Increases performance by collapsing all subpanels when accessing a detailview every time and not querying for data until a user explicitly expands a subpanel  $sugar_config['hide_subpanels'] = true; Hide subpanels per session :  Increases performance by collapsing all subpanels when accessing a detailview when the user logs in but any subpanels expanded during the user's session will remain expanded until the user logs out $sugar_config['hide_subpanels_on_login'] = true;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Sugar_Performance/index.html
d5b44b3248ee-5
$sugar_config['hide_subpanels_on_login'] = true; General Environment Checks Depending on your environment and version of Sugar, there may be additional changes your system administrator can make to improve performance. If your instance is running Sugar 6.3.x or lower, we highly recommend upgrading to 6.4.x or 6.5.x. Beginning in 6.4.x, we made a number of query improvement to address overall application performance. With 6.5.x, we drastically improved the UI to improve the speed of page loads. If your instance of Sugar is version 6.3.x or higher with a MySQL database, we highly recommend upgrading the MySQL 5.5. MySQL 5.5 offers performance improvements in a number of areas over 5.1 such as subselects in queries.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Sugar_Performance/index.html
d5b44b3248ee-6
If you are using MySQL as your database, we strongly recommend using InnoDB. InnoDB is tested to be better performing than MyISAM and should be the default configuration for using MySQL with Sugar. If you are running PHP 5.2.x, we strongly recommend upgrading to a supported version of PHP 5.3. Our current list of supported PHP versions can be found on our Supported Platforms page. If you are using a single server setup (web server and database on the same server), we have the following recommendations. The server should have a minimum of 8 GB of RAM and roughly follow the 60/40 rule (60% for database / 40% for web server). On a 8 GB server, this would mean 4.8 GB for database and 3.2 GB for web server. Make sure the following parameters are set for MySQL (assumption is that the engine is InnoDB)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Sugar_Performance/index.html
d5b44b3248ee-7
innodb_buffer_pool_size = 4294967296 (4 GB in size) innodb_log_buffer_size = anywhere from 10485760 (10 MB - Minimal writes) to 104857600 (100 MB - Lots of writes) If you are using IE 8 or lower, we recommend upgrading to IE 9 or using Google Chrome. Earlier versions of IE 8 exhibit poor performance with our application and we recommend updating your browser to IE 9 or changing to Chrome. PHP Caching Whether your instance of Sugar is deployed on a Linux or Windows server, you should utilize opcode caching to ensure optimal performance. For Linux servers, APC is the recommended opcode cache for PHP with the following guidelines and settings: Use the latest stable version.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Sugar_Performance/index.html
d5b44b3248ee-8
Use the latest stable version. apc.shm size should be close to your program size. For Sugar, that's at least 150 MB (default for apc.shm is 32 MB). When in doubt, more is always better. apc.stat_ctime should be enabled. This will ensure file changes are noticed. You should note that this may increase the stat() activity to your NFS. apc.file_update_protection should be enabled. This helps the system when trying to add multiple files to the cache at the same time. If your installation of Sugar is located on a network filesystem such as NFS or CIFS, make sure apc.stat is enabled. apc.ttl should be set to 0. This parameter disables garbage collection and can cause fragmentation. Earlier APC releases had locking issues that made caches with many entries take forever to be garbage collected.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Sugar_Performance/index.html
d5b44b3248ee-9
apc.shm_segments should be set to the default of 1. If you think you really need multiple shm_segments, you must also read the documentation on apc.mmap_file_mask as well and understand and set that value accordingly. If you don't understand apc.mmap_file_mask, you should leave apc.shm_segments at the default value. APC ships with an additional apc.php file that when hit with a browser, will show settings, cache information, and fragmentation. If you suspect APC problems, this is a great tool to start checking things out. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Sugar_Performance/index.html
f95fc8faca49-0
Integrating Sugar With New Relic APM for Performance Management Overview Sugar® 7 includes support for New Relic APM™, a third-party Application Performance Management (APM) tool that can facilitate deep insight into your Sugar instance in order to troubleshoot sluggish response times. This article explains how to set up and use New Relic in conjunction with Sugar for powerful performance management capabilities. Note: This article pertains to on-site installations of Sugar only. SugarCloud customers who are experiencing performance-related issues should contact the Sugar Support team for assistance. Prerequisites To install and configure New Relic for use with your Sugar instance, you must have Sugar hosted on-site and have access to the root directory.  You must be a New Relic account holder. To sign up for New Relic, please visit newrelic.com to find the subscription level best suited for your needs. Steps to Complete
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Integrating_Sugar_With_New_Relic_APM_for_Performance_Management/index.html
f95fc8faca49-1
Steps to Complete New Relic can provide useful information outside of the Sugar integration, but the feedback it provides will be limited to the instance's PHP file structure, which could make troubleshooting your instance a challenge. Follow these instructions to set up and use New Relic for PHP with your Sugar instance. Installing the New Relic for PHP Agent First, install the New Relic for PHP agent. For the most current installation steps, please refer to the Getting Started Guide on the documentation site for New Relic for PHP. Configuring Sugar to Work With New Relic for PHP Enable the Sugar integration with New Relic by editing the ./config_override.php file. Add the following lines to the end of the file contents (explanation follows): $sugar_config['metrics_enabled'] = 1;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Integrating_Sugar_With_New_Relic_APM_for_Performance_Management/index.html
f95fc8faca49-2
$sugar_config['metrics_enabled'] = 1; $sugar_config['metric_providers']['SugarMetric_Provider_Newrelic'] = 'include/SugarMetric/Provider/Newrelic.php'; $sugar_config['metric_settings']['SugarMetric_Provider_Newrelic']['applicationname'] = "SugarCRM New Relic"; The first line of the configuration enables metrics collection for your Sugar instance. The second line specifies the path where the New Relic provider files can be found. Note: When overwriting the New Relic provider, this path must be changed to the location where the files are located in the ./custom/ directory.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Integrating_Sugar_With_New_Relic_APM_for_Performance_Management/index.html
f95fc8faca49-3
The last line allows you to configure a custom application name so that you may make a distinction between production, staging and development environments. This name will be displayed in your New Relic application list. Simply replace the text inside the double quotes with your desired application name. In the example above, we name the application, "SugarCRM New Relic". Using New Relic for PHP New Relic integrated with Sugar enables you to view the exact functions that cause unusual performance behavior in your instance, such as unexpected triggering of logic hooks, database queries that should be optimized, or customizations that are responding slower than expected. Shortly after completing the configuration steps above, a new application will appear in the New Relic APM interface's application list. Click on the appropriate application's name to view the overview dashboard. Overview Dashboard
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Integrating_Sugar_With_New_Relic_APM_for_Performance_Management/index.html
f95fc8faca49-4
Overview Dashboard The dashboard gives you a quick overview of server response times over a selected period. By default, it will show data collected within the last 30 minutes. To the right of this chart is the Apdex (short for application performance index) chart. Apdex provides an easy way to measure whether performance meets user expectations. In this instance, the Apdex threshold, or T-value, is configured to 0.5 seconds. This means that an app server response time of 0.5 seconds or less is satisfactory for the users, a response time between 0.5 seconds and 2.0 seconds is tolerable, and any value higher than 2.0 seconds becomes frustrating.Â
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Integrating_Sugar_With_New_Relic_APM_for_Performance_Management/index.html
f95fc8faca49-5
The default Apdex T-value for New Relic is 0.5 seconds but it can be configured to match your current environment and user expectations. For information on changing the Apdex T-value, please refer to the Change Your Apdex Settings article in the New Relic documentation. Transactions The Transactions listing is one of the most powerful tools available in New Relic. It will reveal the specific calls or actions that are taking the most time and resources from the server, and speculate as to why. Select "Transactions" in the menu on the left to see a full overview of all the calls done in sugar, sorted by the most time consuming.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Integrating_Sugar_With_New_Relic_APM_for_Performance_Management/index.html
f95fc8faca49-6
In this case, rest_Calls_filterList is selected, which monitors the length of time that it takes to call the Calls module's list view. The performance data for this transaction is displayed on the right. As you can see at the top of the chart, calling the Calls listview has an average response time of 1.5 seconds. Refer to the breakdown table in the lower part of the screen to see which part of the call is taking the most time, with a representation of the performed actions on the database per segment. Below the breakdown table is a list of transaction traces. New Relic will automatically generate a transaction trace when a response time is in the frustrating zone of the Apdex or slower. Click on the transaction trace to learn what is having the negative impact on the performance for this activity.Â
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Integrating_Sugar_With_New_Relic_APM_for_Performance_Management/index.html
f95fc8faca49-7
The transaction trace shows how long various components took to load. In this case, the SELECT query on the Calls table took a significant amount of time. Click on the Trace Details tab above the chart to investigate further. The details page displays specific functions that are being called and how long they took to execute. By drilling down in the tree to the child functions, it is possible to find the root cause of the impaired performance. Scroll down to find the SELECT query on calls took 1 second to load.  Click on the database icon next to the action to reveal the SQL query called by Sugar. To view all SQL queries at once, click on the SQL Statements tab. Summary
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Integrating_Sugar_With_New_Relic_APM_for_Performance_Management/index.html
f95fc8faca49-8
To view all SQL queries at once, click on the SQL Statements tab. Summary For critical business applications like CRM, an APM tool can you help keep your system running fast so end users stay productive and your organization sees a maximum return on investment. An integrated APM will monitor, analyze, and visualize the response times of your application to identify bottlenecks  so that your team can proactively address them.  To learn more about using New Relic for PHP, please visit the New Relic documentation website. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Performance_Tuning/Integrating_Sugar_With_New_Relic_APM_for_Performance_Management/index.html
c44c1ea30e65-0
Caching Overview Much of Sugar's user interface is built dynamically using a combination of templates, metadata and language files. A file caching mechanism improves the performance of the system by reducing the number of static metadata and language files that need to be resolved at runtime. This cache directory stores the compiled files for JavaScript files, Handlebars templates, and language files. In a stock instance, the cache is located in the ./cache/ directory. If you would like to move this directory to a new location, you can update the config parameter cache_dir in config.php or config_override.php to meet your needs. It is not advisable to move the cache to another network server as it may impact system performance. Developer Mode
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Caching/index.html
c44c1ea30e65-1
Developer Mode To prevent caching while developing, a developer may opt to turn on Developer Mode by navigating to Admin > System Settings > Advanced > Developer Mode. This will disable caching so that developers can test code-level customizations without the need to manually rebuild the cache, which is especially helpful when developing templates, metadata, or language files. The system automatically refreshes the file cache. Make sure to deactivate Developer Mode after completing customizations because this mode degrades system performance. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Caching/index.html
71dc8889b38a-0
Web Accessibility Overview Learn about the Sugar Accessibility Plugin for Sidecar. Introduction Making your application accessible -- per the standards defined by the W3C's WAI specifications -- is a hard thing to do and even harder to maintain. The goal of the Sugar Accessibility Plugin for Sidecar is to automatically apply rules to your rendered HTML, so that you don't have to be concerned with all of the intricacies of accessibility. With respect to programmatically applying accessibility rules, you can generally assume that the rules fall into one of three categories: Rules that are dependent on the context of the element's use and cannot be applied programmatically because the context is never clear. Rules that can be applied programmatically, but only when the context is clear. Rules that can always be applied programmatically.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Web_Accessibility/index.html
71dc8889b38a-1
Rules that can always be applied programmatically. We plan to continue to develop this plugin to address more and more accessibility concerns in an abstract way, with the intention of completely covering the latter two cases. In the meantime, the plugin handles two very specific cases: and (2) One from the third category. How It Works The plugin listens to the render event for all View.Component objects that are created. Anytime a component is rendered, the plugin runs its own plugins (hereinafter referred to as "helpers") on the component. Each of these helpers is responsible for determining if any modifications are necessary in order for the component's HTML to meet accessibility standards and then carrying out those changes in the DOM. This behavior is done automatically as a part of the sidecar framework, so you do not need to do anything to start using it.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Web_Accessibility/index.html
71dc8889b38a-2
Sometimes, a component that you write will modify the HTML after it has been rendered. The plugin has no means of becoming aware of these changes to the HTML and you will have to tell it to look for rules to apply. One example is found inView.Fields.Base.ActionmenuField. When the user selects all records in a list view, an alert is flashed indicating that all visible records are now selected. Within this alert, a link can be clicked to select all records, even those that are not currently visible. A new onclick event listener is registered for this link. And because this link is added to the DOM after the component is rendered, the author of the component must make sure that the new HTML meets accessibility requirements. Here is how that is done: var $el = $('a#select-all'); $el.on('click', function() {...}); app.accessiblity.run($el, 'click');
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Web_Accessibility/index.html
71dc8889b38a-3
app.accessiblity.run($el, 'click'); This will only run the click helper. If you want to run all helpers, then call app.accessiblity.run($el) (without the second parameter). But be aware that some helpers only support View.Component objects, while others support eitherView.Component objects or jQuery DOM elements. So running all helpers on a jQuery DOM element may fail, or at least fail to apply some accessibility rules as expected. When the logger is configured for debug mode, messages are logged indicating which helpers are being run and which helpers could not be run when intended. Plugins
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Web_Accessibility/index.html
71dc8889b38a-4
Plugins A plugin (or helper) is a module that applies an accessibility rule to a View.Component (or jQuery DOM element). At runtime, these helpers can be found in app.accessibility.helpers and implement a run method. The run method takes aView.Component (or jQuery DOM element) and then checks its HTML to determine if anything needs to be done in order to make the HTML compliant with accessibility standards related to the rule or task with which the helper is concerned. If any changes are necessary, the helper then modifies the HTML to comply. Click The click helper is responsible for making an element compliant with accessibility standards when click events are bound to said element. Since this helper only deals with onclick events, it only inspects elements within the component that include onclick event listeners.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Web_Accessibility/index.html
71dc8889b38a-5
If the tag name cannot be determined for an element being inspected, then there is no way of knowing whether or not the element is accessible. Thus, the element is assumed to be compliant. Inherently focusable elements are those elements that require no intervention. These elements include: button input select textarea Conditionally focusable elements are those elements that require intervention under certain circumstances. In the case of<a> and <area> tags, these elements are compliant as long as they contain an href attribute. These elements include: a area All other elements are not inherently focusable and require a tabindex attribute of -1 if a tabindex attribute does not already exist. This helper adds tabindex="-1" to any elements within the component that are not compliant. When the logger is configured for debug mode, messages are logged...
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Web_Accessibility/index.html