id
stringlengths
14
16
text
stringlengths
33
5.27k
source
stringlengths
105
270
9072833d365d-1
The after_save hook was added in the 4.5.0c release. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Logic_Hook_Release_Notes/index.html
b0380b913f29-0
SNIP Hooks SNIP hooks execute logic when working with the SNIP email-archiving service. Topicsafter_email_importThe after_email_import hook executes after a SNIP email has been imported.before_email_importThe before_email_import hook executes before a SNIP email has been imported. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/SNIP_Hooks/index.html
cd98285b2ef0-0
before_email_import Overview The before_email_import hook executes before a SNIP email has been imported. Definition function before_email_import($bean, $event, $arguments){} Arguments Name Type Description bean Object The Email object event String The current event arguments Array Additional information related to the event (typically empty) Considerations This is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php. Change Log Version Note 6.5.0RC1 Added before_email_import hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_email_import'] = Array(); $hook_array['before_email_import'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_email_import example', //The PHP file where your class is located. 'custom/modules/SNIP/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'before_email_import_method' ); ?> ./custom/modules/SNIP/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function before_email_import_method($bean, $event, $arguments) { //logic } } ?>   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/SNIP_Hooks/before_email_import/index.html
3476f30e105c-0
after_email_import Overview The after_email_import hook executes after a SNIP email has been imported. Definition function after_email_import($bean, $event, $arguments){} Arguments Name Type Description bean Object The Email object event String The current event arguments Array Additional information related to the event (typically empty) Considerations This is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php. Change Log Version Note 6.5.0RC1 Added after_email_import hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_email_import'] = Array(); $hook_array['after_email_import'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_email_import example', //The PHP file where your class is located. 'custom/modules/SNIP/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'after_email_import_method' ); ?> ./custom/modules/SNIP/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function after_email_import_method($bean, $event, $arguments) { //logic } } ?>   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/SNIP_Hooks/after_email_import/index.html
558f1151461b-0
Job Queue Hooks Job Queue hooks execute logic when working with the Job Queue module. Topicsjob_failureThe job_failure hook executes when a job's final failure occurs.job_failure_retryThe job_failure_retry hook executes each time a job fails before its final failure. If you only want action on the final failure, use the job_failure logic hook. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Job_Queue_Hooks/index.html
924e093af85e-0
job_failure_retry Overview The job_failure_retry hook executes each time a job fails before its final failure. If you only want action on the final failure, use the job_failure logic hook. Definition function job_failure_retry($bean, $event, $arguments){} Arguments Name Type Description bean Object The SchedulersJob object event String The current event arguments Array Additional information related to the event (typically empty) Change Log Version Note 6.5.0RC1 Added job_failure_retry hook Example ./custom/modules/SchedulersJobs/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['job_failure_retry'] = Array(); $hook_array['job_failure_retry'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'job_failure_retry example', //The PHP file where your class is located. 'custom/modules/SchedulersJobs/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'job_failure_retry_method' ); ?> ./custom/modules/SchedulersJobs/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function job_failure_retry_method($bean, $event, $arguments) { //logic } } ?>   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Job_Queue_Hooks/job_failure_retry/index.html
9b551dc178e7-0
job_failure Overview The job_failure hook executes when a job's final failure occurs. Definition function job_failure($bean, $event, $arguments){} Arguments Name Type Description bean Object The SchedulersJob object event String The current event arguments Array Additional information related to the event (typically empty) Change Log Version Note 6.5.0RC1 Added job_failure hook Example ./custom/modules/SchedulersJobs/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['job_failure'] = Array(); $hook_array['job_failure'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'job_failure example', //The PHP file where your class is located. 'custom/modules/SchedulersJobs/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'job_failure_method' ); ?> ./custom/modules/SchedulersJobs/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function job_failure_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Job_Queue_Hooks/job_failure/index.html
b5037fb1c991-0
Web Logic Hooks Overview Web logic hooks let administrators post record and event information to a specified URL when certain sugar events take place. The administration panel for web logic hooks can be found by navigating to Admin > Web Logic Hooks in the Sugar application. When a web logic hook is triggered, Sugar creates a record in the job queue. Note: You must have the cron set up and running in order to process the job queue for web logic hooks. The POST of the information to the external URL will happen when the cron runs and not when the actual event occurs. Arguments Name Description URL The URL to post JSON-encoded information Module Name The name of the module to which the web logic hook will apply Trigger Event The event that will trigger the web logic hookThe following events are applicable to a web logic hook: after_save after_delete after_relationship_add after_relationship_delete after_login after_logout after_login_failed Request Method The request method to use when sending the informationThe following methods may be used: POST GET PUT DELETE Example The following example shows how to receive the information posted to the web logic hook URL parameter. http://{url}/receive.php <?php //get the posted JSON data $data = file_get_contents('php://input'); //decode the data $decoded_data = json_decode(trim($data)); //use the data $file = 'receivedData-'.time().'.txt'; file_put_contents($file, print_r($decoded_data, true)); ?> Result receivedData-1380158171.txt stdClass Object ( [isUpdate] => 1 [dataChanges] => Array ( ) [bean] => Account [data] => stdClass Object (
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Web_Logic_Hooks/index.html
b5037fb1c991-1
[bean] => Account [data] => stdClass Object ( [id] => e0623cdb-ac4b-e7ff-f681-5242e9116892 [name] => Super Star Holdings Inc [date_modified] => 2013-09-25T21:16:06-04:00 [modified_user_id] => 1 [modified_by_name] => admin [created_by] => 1 [created_by_name] => Administrator [description] => [deleted] => [assigned_user_id] => seed_will_id [assigned_user_name] => Will Westin [team_count] => [team_name] => Array ( [0] => stdClass Object ( [id] => East [name] => East [name_2] => [primary] => 1 ) [1] => stdClass Object ( [id] => West [name] => West [name_2] => [primary] => ) ) [linkedin] => [facebook] => [twitter] => [googleplus] => [account_type] => Customer [industry] => Energy [annual_revenue] => [phone_fax] => [billing_address_street] => 111 Silicon Valley Road [billing_address_city] => Los Angeles [billing_address_state] => NY [billing_address_postalcode] => 84028 [billing_address_country] => USA [rating] => [phone_office] => (374) 791-2199 [phone_alternate] =>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Web_Logic_Hooks/index.html
b5037fb1c991-2
[phone_alternate] => [website] => [ownership] => [employees] => [ticker_symbol] => [shipping_address_street] => 111 Silicon Valley Road [shipping_address_city] => Los Angeles [shipping_address_state] => NY [shipping_address_postalcode] => 84028 [shipping_address_country] => USA [email] => Array ( [0] => stdClass Object ( [email_address] => example@example.tw [invalid_email] => [opt_out] => [primary_address] => 1 [reply_to_address] => ) [1] => stdClass Object ( [email_address] => the.example@example.name [invalid_email] => [opt_out] => [primary_address] => [reply_to_address] => ) ) [email1] => example@example.tw [parent_id] => [sic_code] => [parent_name] => [email_opt_out] => [invalid_email] => [campaign_id] => [campaign_name] => ) [event] => after_save ) Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Web_Logic_Hooks/index.html
853bb94cc11c-0
User Hooks User hooks execute logic around user actions such as logging in and logging out. Topicsafter_loginThe after_login hook executes after a user logs into the system.after_logoutThe after_logout hook executes after a user logs out of the system.before_logoutThe before_logout hook executes before a user logs out of the system.login_failedThe login_failed hook executes on a failed login attempt. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/index.html
01d350b4e328-0
after_login Overview The after_login hook executes after a user logs into the system. Definition function after_login($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event (typically empty) Change Log Version Note 5.0.0a Added after_login hook Example ./custom/modules/Users/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_login'] = Array(); $hook_array['after_login'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_login example', //The PHP file where your class is located. 'custom/modules/Users/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'after_login_method' ); ?> ./custom/modules/Users/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function after_login_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/after_login/index.html
b8a5a31eb23c-0
after_logout Overview The after_logout hook executes after a user logs out of the system. Definition function after_logout($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event (typically empty) Change Log Version Note 5.0.0a Added after_logout hook Example ./custom/modules/Users/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_logout'] = Array(); $hook_array['after_logout'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_logout example', //The PHP file where your class is located. 'custom/modules/Users/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'after_logout_method' ); ?> ./custom/modules/Users/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function after_logout_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/after_logout/index.html
746dfacb58a9-0
login_failed Overview The login_failed hook executes on a failed login attempt. Definition function login_failed($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event (typically empty) Change Log Version Note 5.0.0a Added login_failed hook Example ./custom/modules/Users/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['login_failed'] = Array(); $hook_array['login_failed'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'login_failed example', //The PHP file where your class is located. 'custom/modules/Users/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'login_failed_method' ); ?> ./custom/modules/Users/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function login_failed_method($bean, $event, $arguments) { //logic } } ?>   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/login_failed/index.html
55a185decdb9-0
before_logout Overview The before_logout hook executes before a user logs out of the system. Definition function before_logout($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event (typically empty) Change Log Version Note 5.0.0a Added before_logout hook Example ./custom/modules/Users/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_logout'] = Array(); $hook_array['before_logout'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_logout example', //The PHP file where your class is located. 'custom/modules/Users/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'before_logout_method' ); ?> ./custom/modules/Users/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function before_logout_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/before_logout/index.html
5bc3ae9eb5d4-0
API Hooks API hooks execute logic when working with the REST API and routing. Topicsafter_routingThe after_routing hook executes when the v10+ REST Service has found the route for the request.before_api_callThe before_api_call hook executes when the v10+ REST Service is about to call the API implementation.before_filterThe before_filter hook executes when the v10+ REST Service is about to route the request.before_respondThe before_respond hook executes before the v10+ REST Service call returns data to the user.before_routingThe before_routing hook executes when the v10+ REST Service is about to route the request. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/index.html
327f51891971-0
before_respond Overview The before_respond hook executes before the v10+ REST Service call returns data to the user. Definition function before_respond($event, $response){} Arguments Name Type Description event String The name of the logic hook event response Object The RestResponse Object Considerations This is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php. It is not advised to remove or unset any data. Sugar may be using this data and it can adversely affect your instance. This hook should not be used for any type of display output. This hook should be used when you want to add data to all API responses. If you are looking to modify data received from one specific endpoint, It is a much better approach to override that specific endpoint rather than to use this logic hook. Change Log Version Note 7.0.0RC1 Added before_respond hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_respond'] = Array(); $hook_array['before_respond'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_routing example', //The PHP file where your class is located. 'custom/modules/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'before_respond_method' ); ?> ./custom/modules/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/before_respond/index.html
327f51891971-1
class logic_hooks_class { function before_respond_method($event, $response) { //logic } } ?>   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/before_respond/index.html
402672a00221-0
before_api_call Overview The before_api_call hook executes when the v10+ REST Service is about to call the API implementation. Definition function before_api_call($event, $arguments){} Arguments Name Type Description event String The name of the logic hook event arguments Array Additional information related to the event arguments.api Object The RestService Object arguments.request Object The RestResponse Object Considerations This is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php. This hook can change the method being called and the parameters. This hook should not be used for any type of display output. Change Log Version Note 7.0.0RC1 Added before_api_call hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_api_call'] = Array(); $hook_array['before_api_call'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_api_call example', //The PHP file where your class is located. 'custom/modules/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'before_api_call_method' ); ?> ./custom/modules/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function before_api_call_method($event, $arguments) { //logic } } ?>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/before_api_call/index.html
402672a00221-1
{ //logic } } ?>   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/before_api_call/index.html
9b10657648f2-0
after_routing Overview The after_routing hook executes when the v10+ REST Service has found the route for the request. Definition function after_routing($event, $arguments){} Arguments Name Type Description event String The name of the logic hook event arguments Array Additional information related to the event arguments.api Object The RestService Object arguments.request Object The RestResponse Object Considerations This is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php. This hook can change request object parameters that influence routing. This hook should not be used for any type of display output. Change Log Version Note 7.0.0RC1 Added after_routing hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_routing'] = Array(); $hook_array['after_routing'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_routing example', //The PHP file where your class is located. 'custom/modules/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'after_routing_method' ); ?> ./custom/modules/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function after_routing_method($event, $arguments) { //logic } } ?>Â
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/after_routing/index.html
9b10657648f2-1
{ //logic } } ?>  Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/after_routing/index.html
5110ef9d1958-0
before_routing Overview The before_routing hook executes when the v10+ REST Service is about to route the request. Definition function before_routing($event, $arguments){} Arguments Name Type Description event String The name of the logic hook event arguments Array Additional information related to the event arguments.api Object The RestService Object arguments.request Object The RestResponse Object Considerations This is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php. This hook can change request object parameters that influence routing. This hook should not be used for any type of display output. Change Log Version Note 7.0.0RC1 Added before_routing hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_routing'] = Array(); $hook_array['before_routing'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_routing example', //The PHP file where your class is located. 'custom/modules/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'before_routing_method' ); ?> ./custom/modules/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function before_routing_method($event, $arguments) { //logic } } ?>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/before_routing/index.html
5110ef9d1958-1
{ //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/before_routing/index.html
f68f7c59f286-0
before_filter Overview The before_filter hook executes when the v10+ REST Service is about to route the request. Definition function before_filter($bean, $event, $arguments){} Arguments Name Type Description bean Object An empty bean object of the module being queried. event String The name of the logic hook event. arguments Array Additional information related to the event. arguments[0] Object The SugarQuery Object arguments[1] Array The query options Considerations This hook can be executed for a specific module in ./custom/modules/<module>/logic_hooks.php or globally in ./custom/modules/logic_hooks.php. This hook can change request object parameters that influence routing. This hook should not be used for any type of display output. Change Log Version Note 7.0.0RC1 Added before_filter hook Example ./custom/modules/{module}/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_filter'] = Array(); $hook_array['before_filter'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_filter example', //The PHP file where your class is located. 'custom/modules/{module}/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'before_filter_method' ); ?> ./custom/modules/{module}/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/before_filter/index.html
f68f7c59f286-1
class logic_hooks_class { function before_filter_method($bean, $event, $arguments) { //logic } } ?>   Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/API_Hooks/before_filter/index.html
3cfbb4d0fb0a-0
Module Hooks Module hooks execute logic when working with Sugar modules (e.g. Accounts, Cases, etc.). Topicsafter_deleteThe after_delete hook executes after a record is deleted.after_fetch_queryThe after_fetch_query logic hook executes after a sugar query has been executed.after_relationship_addThe after_relationship_add hook executes after a relationship has been added between two records.after_relationship_deleteThe after_relationship_delete hook executes after a relationship between two records has been deleted.after_restoreThe after_restore hook executes after a record gets undeleted (i.e. the deleted field's value changes from 1 to 0).after_retrieveThe after_retrieve hook executes after a record has been retrieved from the database.after_saveThe after_save hook executes after a record is saved.before_deleteThe before_delete logic hook executes before a record is deleted.before_fetch_queryThe before_fetch_query logic hook executes before a sugar query has been executed.before_relationship_addThe before_relationship_add logic hook executes before a relationship has been added between two records.before_relationship_deleteThe before_relationship_delete logic hook executes before a relationship between two records is deleted.before_restoreThe before_restore logic hook executes before a record gets undeleted (i.e. the deleted field's value changes from 1 to 0).before_saveThe before_save logic hook executes before a record is saved.process_recordThe process_record logic hook executes when the record is being processed as a part of the ListView or subpanel list. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/index.html
3a444bbad6e4-0
after_retrieve Overview The after_retrieve hook executes after a record has been retrieved from the database. Definition function after_retrieve($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event arguments.id String ID of the record arguments.encode Boolean Whether or not to encode Considerations The after_retrieve hook does not fire when a new record is being created. Calling save on the bean in this hook can cause adverse side effects if not handled correctly and should be avoided. (i.e. $bean->save()) Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['after_retrieve'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_retrieve example', //The PHP file where your class is located. 'custom/modules/<module>/after_retrieve_class.php', //The class the method is in. 'after_retrieve_class', //The method to call. 'after_retrieve_method' ); ?> ./custom/modules/{module}/{module}_hook.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_retrieve_class { function after_retrieve_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_retrieve/index.html
3a444bbad6e4-1
//logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_retrieve'] = Array(); $hook_array['after_retrieve'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_retrieve example', //The PHP file where your class is located. 'custom/modules/<module>/after_retrieve_class.php', //The class the method is in. 'after_retrieve_class', //The method to call. 'after_retrieve_method' ); ?> ./custom/modules/<module>/after_retrieve_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_retrieve_class { function after_retrieve_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_retrieve/index.html
ebf804abb51d-0
process_record Overview The process_record logic hook executes when the record is being processed as a part of the ListView or subpanel list. Definition function process_record($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event (typically empty) Considerations This can be used to set values in a record's fields prior to display in the ListView or in the subpanel of a DetailView. This event is not fired in the EditView. You should not call save on the referenced bean. The bean is only populated for list fields and will result in a loss of information. Change Log Version Note 5.0.0a Added process_record hook Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['process_record'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'process_record example', //The PHP file where your class is located. 'custom/modules/<module>/process_record_class.php', //The class the method is in. 'process_record_class', //The method to call. 'process_record_method' ); ?> ./custom/modules/<module>/process_record_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class process_record_class { function process_record_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/process_record/index.html
ebf804abb51d-1
//logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['process_record'] = Array(); $hook_array['process_record'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'process_record example', //The PHP file where your class is located. 'custom/modules/<module>/process_record_class.php', //The class the method is in. 'process_record_class', //The method to call. 'process_record_method' ); ?> ./custom/modules/<module>/process_record_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class process_record_class { function process_record_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/process_record/index.html
e7e0a808cd36-0
after_fetch_query Overview The after_fetch_query logic hook executes after a sugar query has been executed. Definition function after_fetch_query($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event arguments.beans Array An array of bean objects resulting from the query arguments.fields Array An array of selected fields arguments.rows Array An array representation of the selected beans  Change Log Version Note 7.7.0.0 Added after_fetch_query logic hook Examples Creating a Logic Hook using Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['after_fetch_query'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_fetch_query example', //The PHP file where your class is located. 'custom/modules/<module>/after_fetch_query_class.php', //The class the method is in. 'after_fetch_query_class', //The method to call. 'after_fetch_query_method' ); ?> ./custom/modules/<module>/after_fetch_query_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_fetch_query_class { function after_fetch_query_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_fetch_query/index.html
e7e0a808cd36-1
//logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_fetch_query'] = Array(); $hook_array['after_fetch_query'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_fetch_query example', //The PHP file where your class is located. 'custom/modules/<module>/after_fetch_query_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'after_fetch_query_method' ); ?> ./custom/modules/<module>/after_fetch_query_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_fetch_query_class { function after_fetch_query_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_fetch_query/index.html
08747081b932-0
after_save Overview The after_save hook executes after a record is saved. Definition function after_save($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event (typically empty) arguments.isUpdate Boolean Whether or not the record is newly created or not. True is an existing record being saved. False is a new record being created arguments.dataChanges Array A list of the fields in the auditable fields on the bean, including the ones that changed and the ones that did not.Note: This argument is deprecated and it is recommended to use arguments.stateChanges instead. arguments.stateChanges Array A list of only the fields in the auditable fields on the bean that changed Considerations Calling save on the bean in this hook will cause an infinite loop if not handled correctly. (i.e: $bean->save()) Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['after_save'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_save example', //The PHP file where your class is located. 'custom/modules/<module>/after_save_class.php', //The class the method is in. 'after_save_class', //The method to call. 'after_save_method' ); ?> ./custom/modules/<module>/after_save_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_save_class {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_save/index.html
08747081b932-1
class after_save_class { function after_save_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_save'] = Array(); $hook_array['after_save'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_save example', //The PHP file where your class is located. 'custom/modules/<module>/after_save_class.php', //The class the method is in. 'after_save_class', //The method to call. 'after_save_method' ); ?> ./custom/modules/<module>/after_save_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_save_class { function after_save_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_save/index.html
f6e44fda226d-0
after_delete Overview The after_delete hook executes after a record is deleted. Definition function after_delete($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event arguments.id String ID of the deleted record Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['after_delete'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_delete example', //The PHP file where your class is located. 'custom/modules/<module>/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'after_delete_method' ); ?> ./custom/modules/<module>/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function after_delete_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_delete'] = Array();
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_delete/index.html
f6e44fda226d-1
$hook_array = Array(); $hook_array['after_delete'] = Array(); $hook_array['after_delete'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_delete example', //The PHP file where your class is located. 'custom/modules/<module>/after_delete_class.php', //The class the method is in. 'after_delete_class', //The method to call. 'after_delete_method' ); ?> ./custom/modules/<module>/after_delete_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_delete_class { function after_delete_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_delete/index.html
6f8310bec170-0
after_restore Overview The after_restore hook executes after a record gets undeleted (i.e. the deleted field's value changes from 1 to 0). Definition function after_restore($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event (typically empty) Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['after_restore'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_restore example', //The PHP file where your class is located. 'custom/modules/<module>/after_restore_class.php', //The class the method is in. 'after_restore_class', //The method to call. 'after_restore_method' ); ?> ./custom/modules/<module>/after_restore_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_restore_class { function after_restore_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_restore'] = Array();
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_restore/index.html
6f8310bec170-1
$hook_array = Array(); $hook_array['after_restore'] = Array(); $hook_array['after_restore'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_restore example', //The PHP file where your class is located. 'custom/modules/<module>/after_restore_class.php', //The class the method is in. 'after_restore_class', //The method to call. 'after_restore_method' ); ?> ./custom/modules/<module>/after_restore_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_restore_class { function after_restore_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_restore/index.html
77be405585d4-0
before_delete Overview The before_delete logic hook executes before a record is deleted. Definition function before_delete($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event arguments.id String ID of the record to delete Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['before_delete'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_delete example', //The PHP file where your class is located. 'custom/modules/<module>/before_delete_class.php', //The class the method is in. 'before_delete_class', //The method to call. 'before_delete_method' ); ?> ./custom/modules/<module>/before_delete_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class before_delete_class { function before_delete_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_delete'] = Array();
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_delete/index.html
77be405585d4-1
$hook_array = Array(); $hook_array['before_delete'] = Array(); $hook_array['before_delete'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_delete example', //The PHP file where your class is located. 'custom/modules/<module>/before_delete_class.php', //The class the method is in. 'before_delete_class', //The method to call. 'before_delete_method' ); ?> ./custom/modules/<module>/before_delete_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class before_delete_class { function before_delete_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_delete/index.html
af25ba96f8af-0
after_relationship_add Overview The after_relationship_add hook executes after a relationship has been added between two records. Definition function after_relationship_add($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event arguments.id String Module ID arguments.module String Module name arguments.related_id String Related module ID arguments.related_module String Related module name arguments.link String Link field name arguments.relationship String Relationship name Considerations This hook will be executed for each side of the relationship. An example is that if you add an association between an Account and Contact, the hook will be run for both. The arguments parameter will have additional information regarding the records being modified. The $bean variable will not contain this information. Change Log Version Note 6.0.0 Added after_relationship_add hook. Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['after_relationship_add'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_relationship_add example', //The PHP file where your class is located. 'custom/modules/{module}/after_relationship_add_class.php', //The class the method is in. 'after_relationship_add_class', //The method to call. 'after_relationship_add_method' ); ?> ./custom/modules/<module>/after_relationship_add_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_relationship_add/index.html
af25ba96f8af-1
class after_relationship_add_class { function after_relationship_add_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_relationship_add'] = Array(); $hook_array['after_relationship_add'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_relationship_add example', //The PHP file where your class is located. 'custom/modules/<module>/after_relationship_add_class.php', //The class the method is in. 'after_relationship_add_class', //The method to call. 'after_relationship_add_method' ); ?> ./custom/modules/<module>/after_relationship_add_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_relationship_add_class { function after_relationship_add_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_relationship_add/index.html
636c1aebed35-0
before_save Overview The before_save logic hook executes before a record is saved. Definition function before_save($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event arguments.check_notify Boolean Whether or not to send notifications arguments.isUpdate Boolean Whether or not the record is newly created true = this is an update to an existing record false = a newly created record Considerations For modules that contain a user-friendly record ID (e.g. the case_number field for the Cases module), the value of that field is not available for a before_save call. This is because this business logic has yet to be executed. Calling save on the bean in this hook will cause an infinite loop if not handled correctly. (i.e: $bean->save()) Examples Creating a Logic Hook using Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['before_save'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_save example', //The PHP file where your class is located. 'custom/modules/<module>/before_save_class.php', //The class the method is in. 'before_save_class', //The method to call. 'before_save_method' ); ?> ./custom/modules/<module>/before_save_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class before_save_class { function before_save_method($bean, $event, $arguments) {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_save/index.html
636c1aebed35-1
function before_save_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_save example', //The PHP file where your class is located. 'custom/modules/<module>/before_save_class.php', //The class the method is in. 'before_save_class', //The method to call. 'before_save_method' ); ?> ./custom/modules/<module>/before_save_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class before_save_class { function before_save_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_save/index.html
b3761eb392ae-0
before_relationship_delete Overview The before_relationship_delete logic hook executes before a relationship between two records is deleted. Definition function before_relationship_delete($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event arguments.id String Module id arguments.module String Module name arguments.related_id String Related module id arguments.related_module String Related module name arguments.link String Link field name arguments.relationship String Relationship name Considerations This hook will be executed for each side of the relationship. For example, if you delete an association between an account and a contact, the hook will run for both records. The arguments parameter will have additional information regarding the records being modified. The $bean variable will not contain this information. Change Log Version Note 6.4.5 Added before_relationship_delete hook. Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['before_relationship_delete'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_relationship_delete example', //The PHP file where your class is located. 'custom/modules/<module>/before_relationship_delete_class.php', //The class the method is in. 'before_relationship_delete_class', //The method to call. 'before_relationship_delete_method' ); ?> ./custom/modules/<module>/before_relationship_delete_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_relationship_delete/index.html
b3761eb392ae-1
class before_relationship_delete_class { function before_relationship_delete_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_relationship_delete/index.html
0cc34231f65e-0
before_restore Overview The before_restore logic hook executes before a record gets undeleted (i.e. the deleted field's value changes from 1 to 0). Definition function before_restore($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event (typically empty) Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_restore example', //The PHP file where your class is located. 'custom/modules/<module>/before_restore_class.php', //The class the method is in. 'before_restore_class', //The method to call. 'before_restore_method' ); ?> ./custom/modules/<module>/before_restore_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class before_restore_class { function before_restore_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_restore'] = Array(); $hook_array['before_restore'][] = Array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_restore/index.html
0cc34231f65e-1
$hook_array['before_restore'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_restore example', //The PHP file where your class is located. 'custom/modules/<module>/before_restore_class.php', //The class the method is in. 'before_restore_class', //The method to call. 'before_restore_method' ); ?> ./custom/modules/<module>/before_restore_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class before_restore_class { function before_restore_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_restore/index.html
3e7b8180786c-0
after_relationship_delete Overview The after_relationship_delete hook executes after a relationship between two records has been deleted. Definition function after_relationship_delete($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event arguments.id String Module ID arguments.module String Module name arguments.related_id String Related module ID arguments.related_module String Related module name arguments.link String Link field name arguments.relationship String Relationship name Considerations This hook will be executed for each side of the relationship. For example, if you delete an association between an account and contact, the hook will run for both. The 'arguments' parameter will have additional information regarding the records being modified. The $bean variable will not contain this information. Change Log Version Note 6.0.0 Added after_relationship_delete hook Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['after_relationship_delete'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_relationship_delete example', //The PHP file where your class is located. 'custom/modules/<module>/after_relationship_delete_class.php', //The class the method is in. 'after_relationship_delete_class', //The method to call. 'after_relationship_delete_method' ); ?> ./custom/modules/<module>/after_relationship_delete_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_relationship_delete/index.html
3e7b8180786c-1
class after_relationship_delete_class { function after_relationship_delete_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_relationship_delete'] = Array(); $hook_array['after_relationship_delete'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_relationship_delete example', //The PHP file where your class is located. 'custom/modules/<module>/after_relationship_delete_class.php', //The class the method is in. 'after_relationship_delete_class', //The method to call. 'after_relationship_delete_method' ); ?> ./custom/modules/<module>/after_relationship_delete_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class after_relationship_delete_class { function after_relationship_delete_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/after_relationship_delete/index.html
47d574635897-0
before_fetch_query Overview The before_fetch_query logic hook executes before a sugar query has been executed. Definition function before_fetch_query($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event arguments.query Object The query to be executed arguments.fields Array An array of selected fields Change Log Version Note 7.7.0.0 Added before_fetch_query logic hook Examples Creating a Logic Hook using Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['before_fetch_query'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_fetch_query example', //The PHP file where your class is located. 'custom/modules/<module>/before_fetch_query_class.php', //The class the method is in. 'before_fetch_query_class', //The method to call. 'before_fetch_query_method' ); ?> ./custom/modules/<module>/before_fetch_query_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class before_fetch_query_class { function before_fetch_query_method($bean, $event, $arguments) { //logic } } ?> Creating a Core Logic Hook
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_fetch_query/index.html
47d574635897-1
//logic } } ?> Creating a Core Logic Hook Prior to Sugar 6.3.x, logic hooks could only be created using the following method. Please note that this approach is still valid but is not recommended when building plugins as it may conflict with existing customizations. ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['before_fetch_query'] = Array(); $hook_array['before_fetch_query'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_fetch_query example', //The PHP file where your class is located. 'custom/modules/<module>/before_fetch_query_class.php', //The class the method is in. 'logic_hooks_class', //The method to call. 'before_fetch_query_method' ); ?> ./custom/modules/<module>/before_fetch_query_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class before_fetch_query_class { function before_fetch_query_method($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_fetch_query/index.html
88822cf2fb69-0
before_relationship_add Overview The before_relationship_add logic hook executes before a relationship has been added between two records. Definition function before_relationship_add($bean, $event, $arguments){} Arguments Name Type Description bean Object The bean object event String The current event arguments Array Additional information related to the event arguments.id String Module ID arguments.module String Module name arguments.related_id String Related module ID arguments.related_module String Related module name arguments.link String Link field name arguments.relationship String Relationship name Considerations This hook will be executed for each side of the relationship. For example, if you add an association between an account and a contact, the hook will run for both records. The arguments parameter will have additional information regarding the records being modified. The $bean variable will not contain this information. Change Log Version Note 6.4.5 Added before_relationship_add hook Examples Creating a Logic Hook using the Extension Framework ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php <?php $hook_array['before_relationship_add'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'before_relationship_add example', //The PHP file where your class is located. 'custom/modules/<module>/before_relationship_add_class.php', //The class the method is in. 'before_relationship_add_class', //The method to call. 'before_relationship_add_method' ); ?> ./custom/modules/<module>/before_relationship_add_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_relationship_add/index.html
88822cf2fb69-1
class before_relationship_add_class { function before_relationship_add($bean, $event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Module_Hooks/before_relationship_add/index.html
bf0a7cd058ac-0
Application Hooks Application hooks execute logic when working with the global application. Topicsafter_entry_pointThe after_entry_point application hook executes at the start of every request.after_load_userThe after_load_user hook executes after the current user is set for the current request. It handles actions that are dependent on the current user, such as setting ACLs or configuring user-dependent parameters.after_session_startThe after_session_start hook executes before the user's session starts, but after the user's visibility rules have been set up and the after_load_user logic hook has executed.after_ui_footerafter_ui_frameThe after_ui_frame hook executes after the frame has been invoked and before the footer has been invoked for modules in backward compatibility mode. This logic hook has been deprecated and will be removed in a future release.entry_point_variables_settingThe entry_point_variables_setting application hook executes at the start of every entry point.handle_exceptionThe handle_exception logic hook executes when an exception is thrown.server_round_tripExecutes at the end of every page. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/index.html
a7a67f7565d6-0
after_load_user Overview The after_load_user hook executes after the current user is set for the current request. It handles actions that are dependent on the current user, such as setting ACLs or configuring user-dependent parameters. Definition function after_load_user($event, $arguments){} Arguments Name Type Description event String The current event arguments Array Additional information related to the event (typically empty) Change Log Version Note 6.6.0 Added after_load_user hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_load_user'] = Array(); $hook_array['after_load_user'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_load_user example', //tde PHP file where your class is located. 'custom/modules/application_hooks_class.php', //tde class the method is in. 'application_hooks_class', //tde method to call. 'after_load_user_method' ); ?> ./custom/modules/application_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class application_hooks_class { function after_load_user_method($event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_load_user/index.html
d3db6be8bf64-0
after_ui_frame Overview The after_ui_frame hook executes after the frame has been invoked and before the footer has been invoked for modules in backward compatibility mode. This logic hook has been deprecated and will be removed in a future release.  Definition function after_ui_frame($event, $arguments){} Arguments Name Type Description event String The current event arguments Array Additional information related to the event (typically empty) Considerations This hook is only applicable for modules in backward compatibility mode. This hook is executed on most views such as the DetailView, EditView, and Listview. Application hooks do not make use of the $bean argument. This is logic hook can be used as a global reference (./custom/modules/logic_hooks.php) or as a module reference (./custom/modules/<module>/logic_hooks.php). Change Log Version Note 7.10.0.0 Deprecated after_ui_frame hook 5.0.0a Added after_ui_frame hook Example Module-Specific Hook This hook can be used at the application level for all modules or limited to specific modules. An example limiting the hook for specific modules is shown below: ./custom/modules/<module>/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_ui_frame'] = Array(); $hook_array['after_ui_frame'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_ui_frame example', //The PHP file where your class is located. 'custom/modules/{module}/logic_hooks_class.php', //The class the method is in. 'logic_hooks_class',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_ui_frame/index.html
d3db6be8bf64-1
//The class the method is in. 'logic_hooks_class', //The method to call. 'after_ui_frame_method' ); ?> ./custom/modules/<module>/logic_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function after_ui_frame_method($event, $arguments) { //display logic } } ?> Application Hook This hook can be used at the application level for all modules or limited to specific modules. An example of executing the hook for all modules is shown below: ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_ui_frame'] = Array(); $hook_array['after_ui_frame'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_ui_frame example', //The PHP file where your class is located. 'custom/modules/application_hooks_class.php', //The class the method is in. 'application_hooks_class', //The method to call. 'after_ui_frame_method' ); ?> ./custom/modules/application_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class application_hooks_class { function after_ui_frame_method($event, $arguments) { //display logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_ui_frame/index.html
e38a379160ba-0
server_round_trip Overview Executes at the end of every page. Definition function server_round_trip($event, $arguments){} Arguments Name Type Description event String The current event arguments Array Additional information related to the event (typically empty) Considerations This is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php. If you are intending to write display logic to the screen, you must first wrap the display logic in an if condition to prevent breaking the Ajax page loads:if (!isset($_REQUEST["to_pdf"]) || $_REQUEST["to_pdf"] == false) { //display logic } This hook is executed on all page loads. Application hooks do not make use of the $bean argument. Change Log Version Note 5.0.0a Added server_round_trip hook. Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['server_round_trip'] = Array(); $hook_array['server_round_trip'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'server_round_trip example', //The PHP file where your class is located. 'custom/modules/application_hooks_class.php', //The class the method is in. 'application_hooks_class', //The method to call. 'server_round_trip_method' ); ?> ./custom/modules/application_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class application_hooks_class {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/server_round_trip/index.html
e38a379160ba-1
class application_hooks_class { function server_round_trip_method($event, $arguments) { //display logic should check for $_REQUEST["to_pdf"] } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/server_round_trip/index.html
8d72fbd4b300-0
after_session_start Overview The after_session_start hook executes before the user's session starts, but after the user's visibility rules have been set up and the after_load_user logic hook has executed. Definition function after_session_start($event, $arguments){} Arguments Name Type Description event String The current event arguments Array Additional information related to the event (typically empty) Change Log Version Note 6.4.3 Added after_session_start hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_session_start'] = Array(); $hook_array['after_session_start'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_session_start example', //The PHP file where your class is located. 'custom/modules/application_hooks_class.php', //The class the method is in. 'application_hooks_class', //The method to call. 'after_session_start_method' ); ?> ./custom/modules/application_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class application_hooks_class { function after_session_start_method($event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_session_start/index.html
e90be05c3e7e-0
handle_exception Overview The handle_exception logic hook executes when an exception is thrown. Definition function handle_exception($event, $exception){} Arguments Name Type Description event String The current event exception Object The exception object Considerations This hook should not be used for any type of display output. You can retrieve the exception message by using $exception->getMessage(). All exception classes extend the PHP Exceptions class. Change Log Version Note 6.4.4 Added handle_exception hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['handle_exception'] = Array(); $hook_array['handle_exception'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'handle_exception example', //The PHP file where your class is located. 'custom/modules/handle_exception_class.php', //The class the method is in. 'handle_exception_class', //The method to call. 'handle_exception_method' ); ?> ./custom/modules/handle_exception_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class handle_exception_class { function handle_exception_method($event, $exception) { //logic with $exception->getMessage() } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/handle_exception/index.html
0ca11f4cf755-0
after_ui_footer Last modified:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_ui_footer/index.html
4883f67075dd-0
entry_point_variables_setting Overview The entry_point_variables_setting application hook executes at the start of every entry point. Definition function entry_point_variables_setting($event, $arguments){} Arguments Name Type Description event String The current event arguments Array Additional information related to the event (typically empty) Considerations The entry_point_variables_setting hook is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php. This hook is executed at the start of every request at the end of ./include/entryPoint.php. This hook does not make use of the $bean argument. Change Log Version Note 6.4.3 Added entry_point_variables_setting hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['entry_point_variables_setting'] = Array(); $hook_array['entry_point_variables_setting'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'entry_point_variables_setting example', //The PHP file where your class is located. 'custom/modules/application_hooks_class.php', //The class the method is in. 'application_hooks_class', //The method to call. 'entry_point_variables_setting_method' ); ?> ./custom/modules/application_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class application_hooks_class { function entry_point_variables_setting_method($event, $arguments) { //logic }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/entry_point_variables_setting/index.html
4883f67075dd-1
{ //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/entry_point_variables_setting/index.html
ea00b1069d6c-0
after_entry_point Overview The after_entry_point application hook executes at the start of every request. Definition function after_entry_point($event, $arguments){} Arguments Name Type Description event String The current event arguments Array Additional information related to the event (typically empty) Considerations The after_entry_point hook is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php. This hook is executed at the start of every request at the end of ./include/entryPoint.php. This hook should not be used for any type of display output. The after_entry_point hook is ideally used for logging or loading libraries. Application hooks do not make use of the $bean argument. Change Log Version Note 6.4.3 Added after_entry_point hook Example ./custom/modules/logic_hooks.php <?php $hook_version = 1; $hook_array = Array(); $hook_array['after_entry_point'] = Array(); $hook_array['after_entry_point'][] = Array( //Processing index. For sorting the array. 1, //Label. A string value to identify the hook. 'after_entry_point example', //The PHP file where your class is located. 'custom/modules/application_hooks_class.php', //The class the method is in. 'application_hooks_class', //The method to call. 'after_entry_point_method' ); ?> ./custom/modules/application_hooks_class.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class application_hooks_class {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_entry_point/index.html
ea00b1069d6c-1
class application_hooks_class { function after_entry_point_method($event, $arguments) { //logic } } ?> Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_entry_point/index.html
3584aebc8ef8-0
Entry Points Overview Entry points, defined in ./include/MVC/Controller/entry_point_registry.php, were used to ensure that proper security and authentication steps are applied consistently across the entire application. While they are still used in some areas of Sugar, any developers using custom entry points should adjust their customizations to use the latest REST API endpoints instead. Accessing Entry Points Available custom entry points can be accessed using a URL pattern as follows: http://{sugar url}/index.php?entryPoint={entry point name} The entry point name will be the specified index in the $entry_point_registry array. Access to this entry point outside of sugar will be dependent on the auth parameter defined in the $entry_point_registry array as well. For more information, refer to the Creating Custom Entry Points page. TopicsCreating Custom Entry PointsAs of 6.3.x, entry points can be created using the extension framework. The entry point extension directory, located at ./custom/Extension/application/Ext/EntryPointRegistry/, is compiled into ./custom/application/Ext/EntryPointRegistry/entry_point_registry.ext.php after a Quick Repair and Rebuild. Additional information can be found in the extensions EntryPointRegistry section. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Entry_Points/index.html
7f273e415c85-0
Creating Custom Entry Points Overview As of 6.3.x, entry points can be created using the extension framework. The entry point extension directory, located at ./custom/Extension/application/Ext/EntryPointRegistry/, is compiled into ./custom/application/Ext/EntryPointRegistry/entry_point_registry.ext.php after a Quick Repair and Rebuild. Additional information can be found in the extensions EntryPointRegistry section. Custom Entry Points Prior to 6.3.x, an entry point could be added by creating the file ./custom/include/MVC/Controller/entry_point_registry.php. This method of creating entry points is still compatible but is not recommended from a best practices standpoint as duplicating ./include/MVC/Controller/entry_point_registry.php to ./custom/include/MVC/Controller/entry_point_registry.php will prevent any upgrader updates to ./include/MVC/Controller/entry_point_registry.php from being reflected in the system. Entry point registries contain two properties: file - The path to the entry point. auth - A Boolean value that determines whether or not the user must be authenticated in order to access the entry point. $entry_point_registry['customEntryPoint'] = array( 'file' => 'path/to/customEntryPoint.php', 'auth' => true ); Example The first step is to create the actual entry point. This is where all of the logic for your entry point will be located. This file can be located anywhere you choose. For my example, I will create: ./custom/customEntryPoint.php <?php if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); echo "Hello World!"; Next, we will need to create our extension in the application extensions. This will be located at: ./custom/Extension/application/Ext/EntryPointRegistry/customEntryPoint.php <?php
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Entry_Points/Creating_Custom_Entry_Points/index.html
7f273e415c85-1
<?php $entry_point_registry['customEntryPoint'] = array( 'file' => 'custom/customEntryPoint.php', 'auth' => true ); Finally, navigate to Admin > Repair > Quick Repair and Rebuild. The system will then generate the file ./custom/application/Ext/EntryPointRegistry/entry_point_registry.ext.php containing your registry entry. We are now able to access our entry point by navigating to: http://{sugar url}/index.php?entryPoint=customEntryPoint Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Entry_Points/Creating_Custom_Entry_Points/index.html
0fec96e0fe0f-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 : ./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?>); 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
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
0fec96e0fe0f-1
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 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. 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
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
0fec96e0fe0f-2
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: 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 : ./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);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Shortcuts/index.html
0fec96e0fe0f-3
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 <?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'; 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
3d98ccab8432-0
Autoloader Overview The autoloader is an API that allows the unified handling of customizations and customizable metadata while reducing the number of filesystem accesses and improving performance. SugarAutoLoader The SugarAutoLoader class, located in ./include/utils/autoloader.php, keeps a map of files within the Sugar directory that may be loaded. Included File Extensions The autoloader will only map files with the following extensions: bmp css gif hbs html ico jpg js less override php png tif tpl xml *All other file extensions are excluded from the mapping. Class Loading Directories The autoloader will scan and autoload classes in the following directories: ./clients/base/api/ ./data/duplicatecheck/ ./data/Relationships/ ./data/visibility/ ./include/ ./include/api/ ./include/CalendarEvents/ ./include/SugarSearchEngine/ ./modules/Calendar/ ./modules/Mailer/ Ignored Directories The following directories in Sugar are ignored by the autoloader mapping: ./.idea/ ./cache/ ./custom/backup/ ./custom/blowfish/ ./custom/Extension/ ./custom/history/ ./custom/modulebuilder/ ./docs/ ./examples/ ./portal/ ./tests/ ./upload/ ./vendor/bin/ ./vendor/HTMLPurifier/ ./vendor/log4php/ ./vendor/nusoap/ ./vendor/pclzip/ ./vendor/reCaptcha/ ./vendor/ytree/ Â
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/index.html
3d98ccab8432-1
./vendor/reCaptcha/ ./vendor/ytree/   TopicsConfiguration APIMethods to configure loading paths for the AutoLoader API.File Check APIFile check methods for use with the AutoLoader API.File Map Modification APIMethods to modify files in the AutoLoader API. All the functions below return true on success and false on failure.Metadata APIMethods to load metadata for the AutoLoader API. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/index.html
1a87c4d45a0c-0
File Check API Overview File check methods for use with the AutoLoader API. existing(...) Returns an array of filenames that exist in the file map. Accepts any number of arguments of which can be filename or array of filenames. If no files exist, empty array is returned. $files = SugarAutoloader::existing('include/utils.php', 'include/TimeDate.php'); existingCustom(...) This method accepts any number of arguments, each of which can be filename or array of filenames. It will return an array of filenames that exist in the file map, adding also files that exist when custom/ is prepended to them. If the original filename already had custom/ prefix, it is not prepended again. custom/ files are added to the list after the root directory files so that if included in order, they will override the data of the root file. If no files exist, empty array is returned. $files = SugarAutoloader::existingCustom('include/utils.php', 'include/TimeDate.php'); existingCustomOne(...) Returns the last file of the result returned by existingCustom(), or null if none exist. Accepts any number of arguments of which can be filename or array of filenames. Since customized files are placed after the root files, it will return customized file if exists, otherwise root file. $files = SugarAutoloader::existingCustomOne('include/utils.php'); You should note that the existingCustomOne() method can be used for loading inline PHP files. An example is shown below: foreach(SugarAutoLoader::existingCustomOne('custom/myFile.php') as $file) { include $file; } Alternative to including inline PHP files, loading class files should be done using requireWithCustom() . fileExists($filename)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Check_API/index.html
1a87c4d45a0c-1
fileExists($filename) Checks if a file exists in the file map. You should note that ".." is not supported by this function and any paths including ".." will return false. The path components should be separated by /. You should also note that multiple slashes are compressed and treated as single slash. $file = 'include/utils.php'; if (SugarAutoloader::fileExists($file)) { require_once($file); } getDirFiles($dir, $get_dirs = false, $extension = null) Retrieves the list of files existing in the file map under the specified directory. If no files are found, the method will return an empty array. By default, the method will return file paths, however, If $get_dirs is set to true, the method will return only directories. If $extension is set, it would return only files having that specific extension. $files = SugarAutoloader::getDirFiles('include'); getFilesCustom($dir, $get_dirs = false, $extension = null) Retrieves the list of files existing in the file map under the specified directory and under it's custom/ path. If no files are found it will return empty array. By default, the method will return file paths, however, If $get_dirs is set to true, the method will return only directories. If $extension is set, it would return only files having that specific extension. $files = SugarAutoloader::getFilesCustom('include'); lookupFile($paths, $file) Looks up a file in the list of given paths, including with and without custom/ prefix, and return the first match found. The custom/ directory is checked before root files. If no file is found, the method will return false. $paths = array( 'include',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Check_API/index.html
1a87c4d45a0c-2
$paths = array( 'include', 'modules', ); $files = SugarAutoloader::lookupFile($paths, 'utils.php'); requireWithCustom($file, $both = false) If a custom/ override of the file or the file exist, require_once it and return true, otherwise return false. If $both is set to true, both files are required with the root file being first and custom/ file being second. Unlike other functions, this function will actually include the file. $file = SugarAutoloader::requireWithCustom('include/utils.php'); You should note that the requireWithCustom() method should be used for loading class files and not inline PHP files. Inline PHP files should be loaded using the existingCustomOne() method. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Check_API/index.html
52b0f92c887f-0
File Map Modification API Overview Methods to modify files in the AutoLoader API. All the functions below return true on success and false on failure. addToMap($filename, $save = true) Adds an existing file to the file map. If $save is true, the new map will be saved to the disk file map, otherwise, it will persist only until the end of the request. This method does not create the file on the filesystem. SugarAutoloader::addToMap('custom/myFile.php'); delFromMap($filename, $save = true) Removes a file from the file map. If $filename points to a directory, this directory and all files under it are removed from the map. If $save is true, the new map will be saved to the disk file map, otherwise, it will persist only until the end of the request. This method does not delete the file from the filesystem. SugarAutoloader::delFromMap('custom/myFile.php'); put($filename, $data, $save = false) Saves data to a file on the filesystem and adds it to the file map. If $save is true, the new map will be saved to the disk file map, otherwise, it will persist only until the end of the request. $file = 'custom/myFile.php'; SugarAutoloader::touch($file, true); SugarAutoloader::put($file, '<?php /*file content*/ ?>', true); touch($filename, $save = false) Creates the specified file on the filesystem and adds it to the file map. If $save is true, the new map will be saved to the disk file map, otherwise, it will persist only until the end of the request. SugarAutoloader::touch('custom/myFile.php', true); unlink($filename, $save = false)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Map_Modification_API/index.html
52b0f92c887f-1
unlink($filename, $save = false) Removes the specified file from the filesystem and from the current file map. If $save is true, the new map will be saved to the disk file map, otherwise, it will persist only until the end of the request. SugarAutoloader::unlink('custom/myFile.php', true); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Map_Modification_API/index.html
13a51e6a8435-0
Metadata API Overview Methods to load metadata for the AutoLoader API. Metadata Loading For the specific sets of metadata, such as detailviewdefs, editviewefs, listviewdefs, searchdefs, popupdefs, and searchfields, a special process is used to load the correct metadata file. You should note that the variable name for the defs, e.g. "detailviewdefs", is usually the same as variable name, except in the case of "searchfields" where it is "SearchFields". The process is described below: If ./custom/modules/{$module}/metadata/{$varname}.php exists, it is used as the data file. If ./modules/{$module}/metadata/metafiles.php or ./custom/modules/{$module}/metadata/metafiles.php exists, it is loaded with the custom file being preferred. If the variable name exists in the data specified by the metafile, the corresponding filename is assumed to be the defs file name. If the defs file name or its custom/ override exists, it is used as the data file (custom one is preferred). If no file has been found yet, ./modules/{$module}/metadata/{$varname}.php is checked and if existing, it is used as the data file. Otherwise, no metadata file is used. loadWithMetafiles($module, $varname) Returns the specified metadata file for a specific module. You should note that due to the scope nature of include(), this function does not load the actual metadata file but will return the file name that should be loaded by the caller. $metadataPath = SugarAutoloader::loadWithMetafiles('Accounts', 'editviewdefs'); loadPopupMeta($module, $metadata = null) Loads popup metadata for either specified $metadata variable or "popupdefs" variable via loadWithMetafiles() and returns it. If no metadata found returns empty array.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/Metadata_API/index.html
13a51e6a8435-1
$popupMetadata = SugarAutoloader::loadPopupMeta('Accounts'); loadExtension($extname, $module = "application") Returns the extension path given the extension name and module. For global extensions, the module should be "application" and may be omitted. If the extension has its own module, such as schedulers, it will be used instead of the $module parameter. You should note that due to the scope nature of include(), this function does not load the actual metadata file but return the file name that should be loaded by the caller. If no extension file exists it will return false. //The list of extensions can be found in ./ModuleInstall/extensions.php $extensionPath = SugarAutoloader::loadExtension('logichooks'); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/Metadata_API/index.html
37ff79c29ad8-0
Configuration API Overview Methods to configure loading paths for the AutoLoader API. addDirectory($dir) Adds a directory to the directory map for loading classes. Directories added should include a trailing "/". SugarAutoloader::addDirectory('relative/file/path/'); addPrefixDirectory($prefix, $dir) Adds a prefix and directory to the $prefixMap for loading classes by prefix. SugarAutoloader::addPrefixDirectory('myPrefix', 'relative/file/path/'); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/Configuration_API/index.html
2bed4a683c7b-0
Email Addresses Overview Recommended approaches when working with email addresses in Sugar. Client Side Recommended approaches when accessing email addresses in Sugar from a client. Sidecar Sidecar is the JavaScript UI framework that users interact within their browsers. Fetching Email Addresses in Sidecar In Sidecar, the email field will return an array of email addresses and their properties for the record. Given the model, you can fetch it using: var emailAddresses = model.get('email'); Note: In the past, developers could use model.get("email1") to fetch the primary email address. While this currently does work, these legacy email fields are deprecated and may be subject to removal in an upcoming Sugar release. Fetching a Primary Email Address in Sidecar To fetch the primary email address for a bean, you can use app.utils.getPrimaryEmailAddress(): var primaryEmailAddress = app.utils.getPrimaryEmailAddress(model); Fetching an Email Address by Properties in Sidecar To fetch an email address based on properties such as invalid_email, you can use app.utils.getEmailAddress(). This function will return the first email address that matches the options or an empty string if not found. An example is shown below: var emailAddress = app.utils.getEmailAddress(model, {invalid_email: true}); If you have complex filtering rules, you can use _.find() to fetch an email address: var emailAddress = _.find(model.get('email'), function(emailAddress){ if (emailAddress.invalid_email == true) { return emailAddress; } }); Validating Email Addresses in Sidecar To validate an email address, you can use app.utils.isValidEmailAddress(): var isValid = app.utils.isValidEmailAddress(emailAddress);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email_Addresses/index.html
2bed4a683c7b-1
var isValid = app.utils.isValidEmailAddress(emailAddress); Note: This function is more permissive and does not conform exactly to the RFC standards used on the server. As such, the email address will be validated again on the server when the record is saved, which could still fail validation. More information can be found in the email address validation section. Iterating Email Address in Sidecar To iterate through email addresses on a model, you can use _.each(): _.each(model.get('email'), function(emailAddress) { console.log(emailAddress.email_address); }); Updating Email Addresses in Sidecar This section covers how to manipulate the email addresses for a model. Adding Email Addresses in Sidecar In Sidecar, you can add email addresses to a model using the custom function below: function addAddress(model, email) { var existingAddresses = model.get('email') ? app.utils.deepCopy(model.get('email')) : [], dupeAddress = _.find(existingAddresses, function(address){ return (address.email_address === email); }), success = false; if (_.isUndefined(dupeAddress)) { existingAddresses.push({ email_address: email, primary_address: (existingAddresses.length === 0), opt_out: app.config.newEmailAddressesOptedOut || false }); model.set('email', existingAddresses); success = true; } return success; } Removing Email Addresses in Sidecar In Sidecar, you can remove email addresses from a model using the custom function below: function removeAddress(model, email) { var existingAddresses = app.utils.deepCopy(model.get('email')); var index = false; _.find(existingAddresses, function(emailAddress, idx){
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email_Addresses/index.html
2bed4a683c7b-2
_.find(existingAddresses, function(emailAddress, idx){ if (emailAddress.email_address === email) { index = idx; return true; } }); var primaryAddressRemoved = false; if (index !== false) { primaryAddressRemoved = !!existingAddresses[index]['primary_address']; } //Reject this index from existing addresses existingAddresses = _.reject(existingAddresses, function (emailInfo, i) { return i == index; }); // If a removed address was the primary email, we still need at least one address to be set as the primary email if (primaryAddressRemoved) { //Let's pick the first one var address = _.first(existingAddresses); if (address) { address.primary_address = true; } } model.set('email', existingAddresses); return primaryAddressRemoved; } Server Side Recommended approaches when accessing email addresses in Sugar from the server. SugarBean The SugarBean is Sugars PHP core object model. Fetching Email Addresses Using the SugarBean Using the SugarBean, the $bean->emailAddress->addresses property will return an array of email addresses and its properties. The $bean->emailAddress property makes use of the EmailAddress class which is located in ./modules/EmailAddresses/EmailAddress.php. An example is shown below: $emailAddresses = $bean->emailAddress->addresses; Fetching a Primary Email Address Using the SugarBean To fetch the primary email address for a bean, you can use $bean->emailAddress->getPrimaryAddress(): $primaryEmailAddress = $bean->emailAddress->getPrimaryAddress($bean); Another alternative is to use the email_addresses_primary relationship: $primaryEmailAddress = false;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email_Addresses/index.html
2bed4a683c7b-3
$primaryEmailAddress = false; if ($this->load_relationship('email_addresses_primary')) { $relatedBeans = $this->email_addresses_primary->getBeans(); if (!empty($relatedBeans)) { $primaryEmailAddress = current($relatedBeans); } } You may also choose to iterate the email address list with a foreach(). An example function is shown below: function getPrimaryEmailAddress($bean) { foreach ($bean->emailAddress->addresses as $emailAddress) { if ($emailAddress['primary_address'] == true) { return $emailAddress; } } return false; } Fetching an Email Address by Properties Using the SugarBean To fetch an email address based on properties such as invalid_email, you can use a foreach(): $result = false; foreach ($bean->emailAddress->addresses as $emailAddress) { if ($emailAddress['invalid_email']) { $result = $emailAddress; break; } } Validating Email Addresses Using the SugarBean To validate an email address, you can use $bean->emailAddress->isValidEmail(): $isValid = $bean->emailAddress->isValidEmail($emailAddress); Note: The EmailAddress::isValidEmail method leverages the PHPMailer library bundled with Sugar, specifically the PHPMailer::validateAddress method, which validates the address according to the RFC 5321 and RFC 5322 standards. More information can be found in the email address validation section. Iterating Email Addresses Using the SugarBean To iterate through email addresses on a bean, you can use foreach(): foreach ($bean->emailAddress->addresses as $emailAddress) { $GLOBALS['log']->info($emailAddress['email_address']); } Fetching Beans by Email Address Using the SugarBean
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email_Addresses/index.html
2bed4a683c7b-4
} Fetching Beans by Email Address Using the SugarBean To fetch all beans related to an email address you can use getBeansByEmailAddress(): $beans = $bean->emailAddress->getBeansByEmailAddress($emailAddress); If you don't have a bean available, you may choose to create a new EmailAddress object: $sea = BeanFactory::newBean('EmailAddresses'); $sea->getBeansByEmailAddress($emailAddress); Updating Email Addresses Using the SugarBean This section covers how to manipulate the email addresses for a bean. Adding Email Addresses Using the SugarBean To add an email address to the bean, you can use $bean->emailAddress->addAddress(): $bean->emailAddress->addAddress('address@sugar.crm'); Note: The addAddress() function has additional parameters that are defaulted for determining if the email address is a primary, reply to, invalid, or opted out email address. You can also specify an id for the email address and whether or not the email address should be validated. function addAddress($addr, $primary=false, $replyTo=false, $invalid=false, $optOut=false, $email_id = null, $validate = true) Removing Email Addresses Using the SugarBean To remove an email address you can use $bean->emailAddress->removeAddress(): $bean->emailAddress->removeAddress('address@sugar.crm'); PDF Templates Using the Sugar PDF templates, you can reference the primary email address of the bean using: {$fields.email_addresses_primary.email_address} REST API Sugar comes out of the box with an API that can be called from custom applications utilizing the REST interface. The API can be used to mass create and update records in Sugar with external data. For more information on the REST API in Sugar, please refer to the Web Services documentation. Creating Email Addresses Using the REST API
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email_Addresses/index.html
2bed4a683c7b-5
Creating Email Addresses Using the REST API When creating records in Sugar through the API, modules with relationships to email addresses can utilize the email link field to specify email addresses for a record. Using the email link field, you can specify multiple email addresses to assign to the record. You may specify the following additional information regarding each email address being added: Property Description invalid_email Specify this email address as being invalid opt_out Specify this email address as being opted out. More information on opt-outs can be found in the Emails documentation. primary_address Specify this email address as the primary Using the /<module> POST endpoint, you can send the following JSON payload to create a contact record with multiple email addresses using the email link field: POST URL: http://<site url>/rest/v<version>/Contacts { "first_name":"Rob", "last_name":"Robertson", "email":[ { "email_address":"rob.robertson@sugar.crm", "primary_address":"1", "invalid_email":"0", "opt_out":"0" }, { "email_address":"rob@sugar.crm", "primary_address":"0", "invalid_email":"0", "opt_out":"1" } ] } For more information on the /<module>/:record POST endpoint, you can refer to your instance's help documentation found at: http://<site url>/rest/v<version>/help Or you can reference the <module> POST PHP example. Updating Email Addresses Using the REST API
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email_Addresses/index.html
2bed4a683c7b-6
Updating Email Addresses Using the REST API When updating existing records in Sugar through the API, modules with relationships to email addresses can use the email link field to specify email addresses for a record. Using the email link field, you can specify multiple email addresses to update the record with. You may specify the following additional information regarding each email address being added: invalid_email : Specify this email address as being invalid opt_out : Specify this email address as being opted out primary_address : Specify this email address as the primary Using the /<module>/:record PUT endpoint, you can send the following JSON payload to update a contact record with multiple email addresses: PUT URL: http://<site url>/rest/v<version>/Contacts/<record id> { "email":[ { "email_address":"rob.robertson@sugar.crm", "primary_address":"1", "invalid_email":"0", "opt_out":"0" }, { "email_address":"rob@sugar.crm", "primary_address":"0", "invalid_email":"0", "opt_out":"1" } ] } For more information on the /<module>/:record PUT endpoint, you can refer to your instance's help documentation found at: http://<site url>/rest/v<version>/help You want to reference the <module>/:record PUT PHP example. Legacy Email Fields The legacy email fields in Sugar are deprecated and may be subject to removal in an upcoming Sugar release. When using the email1 field, the default functionality is to import the email address specified as the primary address. Legacy Email Field Description email1 The text value of primary email address. Does not indicate if the email address is valid or opted-out. email2
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email_Addresses/index.html
2bed4a683c7b-7
email2 The text value of first non-primary email address. Does not indicate if the email address is valid or opted-out. Note: For importing multiple email addresses with properties, you will need to use the email link field. Creating Email Addresses Using Direct SQL When importing records into Sugar directly via the database, it is important that you understand the data structure involved before loading data. Email addresses are not stored directly on the table for the module being imported in but are related via the email_addr_bean_rel table. The table structure for email addresses can be seen from the database via the following SQL statement: SELECT email_addr_bean_rel.bean_id, email_addr_bean_rel.bean_module, email_addresses.email_address FROM email_addr_bean_rel INNER JOIN email_addresses ON email_addresses.id = email_addr_bean_rel.email_address_id AND email_addr_bean_rel.deleted = 0 WHERE email_addresses.deleted = 0; Checking for Duplicates Email addresses can become duplicated in Sugar from a variety of sources including API calls, imports, and from data entry. There are a few ways to have the system check for duplicate contact records, but not many of those methods work for checking email addresses for duplicates. The following section will demonstrate how to find and clean up duplicate email addresses using SQL. The following SQL query can be used to locate if any email addresses are being used against more than one bean record within Sugar: SELECT email_addresses.email_address, COUNT(*) AS email_address_count FROM email_addr_bean_rel INNER JOIN email_addresses ON email_addresses.id = email_addr_bean_rel.email_address_id AND email_addr_bean_rel.deleted = 0 WHERE email_addresses.deleted = 0 GROUP BY email_addresses.email_address HAVING COUNT(*) > 1;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email_Addresses/index.html
2bed4a683c7b-8
GROUP BY email_addresses.email_address HAVING COUNT(*) > 1; Note: If you convert a Lead record to a Contact record, both the Lead and the Contact will be related to the same Email Address and will return as having duplicates in this query. You can add the following line to the WHERE clause to filter the duplicate check down to only one bean type: AND email_addr_bean_rel.bean_module = 'Contacts' Email addresses can not only be duplicated in the system but can occasionally be missing critical data. Each bean record with an email address assigned to it should have an email address designated the primary. The following query will locate any bean records that have at least one email address, where there is not an email address designated as the primary: SELECT email_addr_bean_rel.bean_module, email_addr_bean_rel.bean_id, COUNT(*) AS email_count, COUNT(primary_email_addr_bean_rel.id) AS primary_email_count FROM email_addr_bean_rel LEFT JOIN email_addr_bean_rel primary_email_addr_bean_rel ON primary_email_addr_bean_rel.bean_module = email_addr_bean_rel.bean_module AND primary_email_addr_bean_rel.bean_id = email_addr_bean_rel.bean_id AND primary_email_addr_bean_rel.primary_address = '1' AND primary_email_addr_bean_rel.deleted = '0' WHERE email_addr_bean_rel.deleted = '0' GROUP BY email_addr_bean_rel.bean_module, email_addr_bean_rel.bean_id HAVING primary_email_count < 1; Note: If you are a SugarCloud customer, you can open up a case with Sugar Support to have this query run for you. Removing Duplicates If it is determined you have duplicate email addresses being used in your system, you can use the following query to clean up the records: START TRANSACTION; CREATE
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email_Addresses/index.html
2bed4a683c7b-9
START TRANSACTION; CREATE TABLE email_addr_bean_rel_tmp SELECT * FROM email_addr_bean_rel WHERE deleted = '0' GROUP BY email_address_id, bean_module, bean_id ORDER BY primary_address DESC; TRUNCATE TABLE email_addr_bean_rel; INSERT INTO email_addr_bean_rel SELECT * FROM email_addr_bean_rel_tmp; SELECT COUNT(*) AS repetitions, date_modified, bean_id, bean_module FROM email_addr_bean_rel WHERE deleted = '0' GROUP BY bean_id, bean_module, email_address_id HAVING repetitions > 1; COMMIT; Note: If you are a SugarCloud customer, you can open up a case with Sugar Support to have this query run for you. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email_Addresses/index.html
032ec26b25b8-0
Tags Overview The tagging feature allows a user to apply as many "tags" as they choose on any record they want to categorize. This allows the user to effectively group records together from any source within the application and relate them together. Please note that the tag field and Tags module do not support customization at this time. The Tags Module The Tags module is a very simple module based on the Basic SugarObject template. It is not studio editable, is part of the default module list, and is available to the application upon installation. By default, the Tags module is set up such that only an Administrator can perform any administrative tasks with the Tags module. In other words, a regular user will have a very restrictive set of permissions inside the Tags module, namely: create, export, view, and share. All other actions within the Tags modules must be carried out by an Administrative user. The "tag" Field Type The back end utilizes two new field types: the relatecollection field and the tag field. The tag field is a relatecollection type field with a few added enhancements specific to the tagging implementation: Enforces uniqueness of a tag when created Establishes the necessary relationship between the Tags module and the module record being tagged Collects and formats a tag collection in a way the client understands Format the tag field for consumption by and from the import process Handles proper query setting for a search that is filtered by tags The Taggable Implementation The taggable implementation is applied to all SugarObject templates so that it is available on all custom modules created and is also applied to all sidecar enabled modules. Any module that implements a SugarObject template will be taggable by default. Any module that doesn't implement a SugarObject template can easily apply it using the uses property of the module vardefs: $dictionary[$module] = array( ... 'uses' => array( 'taggable', ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Tags/index.html
032ec26b25b8-1
... 'uses' => array( 'taggable', ), ... ); There may be instances where a module should not implement tagging yet implements the SugarObject template. To remove tagging from a module you can use the module vardefs ignore_templates property: $dictionary[$module] = array( ... 'ignore_templates' => array( 'taggable', ), ... ); The Tagging Relationship Structure The tagging relationship schema is similar in nature to the email_addresses relationship schema in that it is used to represent a collection of 0-N Tags module records related to a module: Column Description id The GUID for the relationship between the tag record and the module record tag_id The id of the tag record used in this relationship bean_id The id of the module record used in this relationship bean_module The module for the record being tagged date_modified The date the relationship was created/modified deleted A tinyint(1) boolean value that indicates whether this relationship is deleted Tagging in Action For adding tags from the UI, please refer to the Tags documentation. Tagging Records from the API Tagging a record via the API is done by sending a PUT request to the /<module>/<record> API endpoint with a tag property set to an array of key/value pairs that include a tag id (optional) and a tag name: { "name": "Record Name", "tag": [ {"id": "Test Tag", "name": "Test Tag"}, {"name": "Test Tag 2"}, {"id": "1234-56-7890", "name": "Test Tag 3"} ] }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Tags/index.html
032ec26b25b8-2
] } After the record is created/modified and the tag values are applied, the response will contain the returned collection of tags for that record complete with their ids: { "name": "Record Name", "tag": [ {"id": "9876-54-3210", "name": "Test Tag"}, {"id": "4321-56-0987", "name": "Test Tag 2"}, {"id": "1234-56-7890", "name": "Test Tag 3"} ] } You can visit How to Manipulate Tags (CRUD) for a full example demonstrating CRUD actions for tags. Mass Updating Tags on Records Via the API Mass updating records with tags are as simple as sending a MassUpdate PUT request to /<module>/MassUpdate with a payload similar to: { "massupdate_params": { "uid": ["12345-67890", "09876-54321"], "tag": [ { "id": "23456-78901", "name": "MyTag1" }, { "id": "34567-89012", "name": "MyTag2" } ] } } This request will override all existing tags on the named records. To append tags to a record, send the "tag_type" request argument set to a value of 1: { "massupdate_params": { "uid": ["12345-67890", "09876-54321"], "tag": [ { "id": "23456-78901", "name": "MyTag1" }, { "id": "34567-89012", "name": "MyTag2" }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Tags/index.html
032ec26b25b8-3
], "tag_type": "1" } } More information on this API endpoint can be found in the /<module>/MassUpdate PUT documentation. Fetching Tags on a Record By default, the tag field is added to all Sidecar module record views. That means when a request is made for a single record through the API, that single record will return the "tag" field, which will be a collection of key:value pair objects. For example, when a request is made to the /Accounts/:record GET endpoint, the tags associated with the Accountrecord  will be returned in the tag field as an array of objects: { "id": "<record>", "name": "Record Name", "tag": [ { "id": "9876-54-3210", "name": "Test Tag" }, { "id": "4321-56-0987", "name": "Test Tag 2" }, { "id": "1234-56-7890", "name": "Test Tag 3" } ] } Filtering a Record List by Tags Filtering a list of records by tags can be done simply by sending a filter request to the ModuleApi endpoint for a module. For example, to filter the Accounts list where the tag field has a tag by the name of "Tradeshow", you can send a request to the /Accounts GET endpoint with the following request arguments: { "view": "list", "filter": [ { "tag": { "$in": [ { "name": "Tradeshow" } ] } } ] } Currently, the tag field filter definitions support the following filter operators:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Tags/index.html
032ec26b25b8-4
] } Currently, the tag field filter definitions support the following filter operators: Is any of ($in) Is not any of ($not_in) Is empty ($empty) Is not empty ($not_empty) Fetching a list of Tags from the Tags module Fetch a list of tag records from the Tags module is done the same way as fetch a list of records from any other module, namely by sending a GET request to the /Tags ModuleApi endpoint. More information can be found in the /<module> GET documentation. Manipulating Tags Programmatically Getting Tags Related to a Record Here is an example that demonstrates how to get all the tags and its ids related to a contact record: // Creating a Bean for Contacts $bean = BeanFactory::getBean("Contacts"); // Creating a Bean for Tags $tagBean = BeanFactory::newBean('Tags'); // Get all the tags related to Contacts Bean by givin Contact ID. You can provide more than one Record ID. $tags = $tagBean->getRelatedModuleRecords($bean, ["<CONTACT_RECORD_ID>"]); Creating a New Tag and Adding to a Record Here is an example that demonstrates how to add create a tag and add to a contact record. In order to add a new tag first, we will create the tag bean. Then using load_relationship function we will add the newly created tag id to the contacts  // Creating new Tag Bean $tagBean = BeanFactory::newBean("Tags"); // Setting its name $tagBean->name = "New Tag"; $tagBean->save(); // Retrieving the Contacts Bean $bean = BeanFactory::getBean("Contacts", "<RECORD_ID>"); // Getting tag field and its properties $tagField = $bean->getTagField();
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Tags/index.html