id
stringlengths 14
16
| text
stringlengths 33
5.27k
| source
stringlengths 105
270
|
---|---|---|
b76e20c37238-2 | Removing Teams
To remove a team from a bean, you will need to load the team's relationship and use the remove() method. This method accepts an array of team ids to remove. An example is shown below:
//Retrieve the bean
$bean = BeanFactory::getBean($module, $record_id);
//Load the team relationship
$bean->load_relationship('teams');
//Remove the teams
$bean->teams->remove(
array(
$team_id_1,
$team_id_2
)
);
Considerations
If removing teams in a logic hook, the recommended approach is to use an after_save hook rather than a before_save hook as the $_REQUEST may reset any changes you make.
Replacing Team Sets | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Manipulating_Teams_Programmatically/index.html |
b76e20c37238-3 | Replacing Team Sets
To replace all of the teams related to a bean, you will need to load the team's relationship and use the replace() method. This method accepts an array of team ids. An example is shown below:
//Retrieve the bean
$bean = BeanFactory::getBean($module, $record_id);
//Load the team relationship
$bean->load_relationship('teams');
//Set the primary team
$bean->team_id = $team_id_1
//Replace the teams
$bean->teams->replace(
array(
$team_id_1,
$team_id_2
)
);
//Save to update primary team
$bean->save()
Considerations | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Manipulating_Teams_Programmatically/index.html |
b76e20c37238-4 | );
//Save to update primary team
$bean->save()
Considerations
If replacing teams in a logic hook, the recommended approach is to use an after_save hook rather than a before_save hook as the $_REQUEST or workflow may reset any changes you make.
This method does not replace (or set) the primary team for the record. When replacing teams, you need to also make sure that the primary team, determined by the team_id field, is set appropriately and included in the replacement ids. If this is being done in a logic hook you should set the primary team in a before_save hook and replace the team set in the after_save hook.
When using an after_save hook, be sure to call $bean->teams->setSaved(false) to explicitly reset the save state. This ensures that the updates to the team sets are applied.
Example:
//before save function | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Manipulating_Teams_Programmatically/index.html |
b76e20c37238-5 | Example:
//before save function
public function before_save_hook($bean, $event, $arguments)
{
$bean->team_id = $team_id_1;
}
//after save function
public function after_save_hook($bean, $event, $arguments)
{
$bean->teams->setSaved(false); // Manually reset TeamSet state for save
$bean->teams->replace(
array(
$team_id_1,
$team_id_2
)
);
}
Creating and Retrieving Team Set IDs | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Manipulating_Teams_Programmatically/index.html |
b76e20c37238-6 | )
);
}
Creating and Retrieving Team Set IDs
To create or retrieve the team_set_id for a group of teams, you will need to retrieve an instance of a TeamSet object and use the addTeams() method. If a team set does not exist, this method will create it and return an id. An example is below:
//Create a TeamSet bean - no BeanFactory
require_once 'modules/Teams/TeamSet.php';
$teamSetBean = new TeamSet();
//Retrieve/create the team_set_id
$team_set_id = $teamSetBean->addTeams(
array(
$team_id_1,
$team_id_2
)
);
Adding Additional Access | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Manipulating_Teams_Programmatically/index.html |
b76e20c37238-7 | $team_id_2
)
);
Adding Additional Access
To enable additional access for a record, you can either set the team id or team set to the beans acl_team_set_id field. An example of this is shown below:
require_once 'modules/Teams/TeamSet.php';
// Create a new teamset or fetch the id of an existing teamset
$teamSetBean = new TeamSet();
$teamSetId = $teamSetBean->addTeams([
'East', // Demo Team ID
'West', // Demo Team ID
]);
$bean = BeanFactory::getBean('Accounts', '15bcf01c-1e1e-11e8-9e13-f45c89a8598f');
// Set additional access | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Manipulating_Teams_Programmatically/index.html |
b76e20c37238-8 | // Set additional access
$bean->acl_team_set_id = $teamSetId; // if set to NULL, this will remove any existing value
$bean->save();
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Manipulating_Teams_Programmatically/index.html |
2e0ca08a81a7-0 | Themes
Overview
How to customize the Sugar theme.Â
Theme Variables
Sugar's theme variables, defined in ./styleguide/themes/clients/base/default/variables.php, determine the color of the primary action buttons, links, and header navigation. An example of the definition is shown below:
./styleguide/themes/clients/base/default/variables.php
$lessdefs = array(
'colors' => array(
/**
* Secondary Color:
* color of the navbar
* -------------------------
* was @secondary
*/
'NavigationBar' => '#fff',
/**
* Primary Button Color:
* color of the primary button
* ------------------------- | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-1 | * color of the primary button
* -------------------------
* was @primaryBtn
*/
'PrimaryButton' => '#0679c8',
),
);
Variable Descriptions
It is important to understand what the purpuse and utility of each variable is before you apply in your code, below is an in-depth description:
@NavigationBar
Used to customize the mega menu background colourÂ
Defaults to Sugar's @white (#ffffff)Â
Note: This variable is only supported in light mode
@PrimaryButton
Used to customize the background colour for primary buttons (elements using `btn btn-primary`)Â
Defaults to Sugar's @blue (#0679c8)Â
@LinkColor Â
Used to customize the text color of link (anchor) elements | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-2 | Used to customize the text color of link (anchor) elementsÂ
Defaults to Sugar's @blue (#0679c8)Â
Note: This variable is only supported in light mode
Custom Themes
Modifications to the theme can be made by creating ./custom/themes/clients/base/default/variables.php. Within this file, you can define the custom hex codes for the colors you would like to use. You should note that this is limited to the @NavigationBar, and @PrimaryButton less variables. An example is shown below.
 ./custom/themes/clients/base/default/variables.php
Note: Developers cannot override existing bootstrap less variables using this file.
Adding CSS | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-3 | Adding CSS
Sugar allows you to customize CSS using the less language in ./custom/themes/custom.less. As Sugar makes use of the Bootstrap library, you have access to the features of Bootstrap and can make use of its variables to create your own CSS. An example is shown below.Â
./custom/themes/custom.less
//You can import any less file you want and define your own file structure
//@import 'anyotherfile.less
@myCustomBgColor: lighten(@NavigationBar,10%); //variable defined on a custom variable.
.myCustomClass {
color: @linkColor; //bootstrap variable
background-color: @myCustomBgColor;
}
Overriding CSS Definitions | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-4 | }
Overriding CSS Definitions
You can use the ./custom/themes/custom.less file to override CSS classes. The following example overrides the record label font size.
./custom/themes/custom.less
/*
* Changes record field label sizes to 13px;
*/
.record-cell .record-label{
font-size:13px;
}
Overriding the MegaMenu
As the MegaMenu has limited color customization within ./custom/themes/clients/base/default/variables.php, you may want to customize the look and feel further. The following example will automatically set the menu's link color to a contrasting color based on the @NavigationBar variable and determine the hover and active colors for the tabs.  | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-5 | ./custom/themes/custom.less
// Workaround for luminance calculation
// Use luma() function once Sugar upgraded Lessphp to 1.7+ (see: http://lesscss.org/functions/#color-channel-luminance)
@luma: 1 - ( (0.299 * red(@NavigationBar)) + (0.587 * green(@NavigationBar)) + (0.114 * blue(@NavigationBar)))/255;
/**
* LESS GUARDS
*/
// General Nav Colors
.mixin-color() {
// Darker Colors
& when (@luma > 0.5) {
color: darken(contrast(@NavigationBar), 10%) !important;
}
// Bright Colors
& when (@luma <= 0.5) { | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-6 | // Bright Colors
& when (@luma <= 0.5) {
color: lighten(contrast(@NavigationBar), 10%) !important;
// color: darken(@NavigationBar, 30%) !important;
}
}
// Nav Fa Icon Colors
.mixin-fa-color(){
// Darker Colors
& when (@luma > 0.5) {
color: darken(contrast(@NavigationBar), 10%) !important;
}
// Bright Colors
& when (@luma <= 0.5) {
// color: lighten(@NavigationBar, 30%);
color: lighten(contrast(@NavigationBar), 10%) !important;
// color: darken(@NavigationBar, 30%) !important;
}
} | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-7 | }
}
// Hover Button Groups Background colors
.mixin-background-color-hover(){
// Dark Colors
& when (@luma > 0.5) {
background-color: lighten(@NavigationBar, 15%) !important;
}
// Bright Colors
& when (@luma <= 0.5) {
background-color: darken(@NavigationBar, 15%) !important;
}
}
// Hover Button Groups colors
.mixin-color-hover(){
// Dark Colors
& when (@luma > 0.5) {
color: darken(contrast(@NavigationBar), 10%) !important;
}
// Bright Colors
& when (@luma <= 0.5) {
// color: lighten(@NavigationBar, 20%) !important; | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-8 | // color: lighten(@NavigationBar, 20%) !important;
color: lighten(contrast(@NavigationBar), 10%) !important;
}
}
// Active Button Group Background Colors
.mixin-background-color-active(){
// Dark Colors
& when (@luma > 0.5) {
background-color: lighten(@NavigationBar, 10%) !important;
}
// Bright Colors
& when (@luma <= 0.5) {
background-color: darken(@NavigationBar, 10%) !important;
}
}
// Active Button Group Hover Colors
.mixin-color-active-hover(){
// Dark Colors
& when (@luma > 0.5) {
color: darken(contrast(@NavigationBar), 5%) !important; | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-9 | color: darken(contrast(@NavigationBar), 5%) !important;
}
// Bright Colors
& when (@luma <= 0.5) {
color: lighten(contrast(@NavigationBar), 5%) !important;
}
}
// Open Button Group Background Colors
.mixin-background-color-open(){
// Dark Colors
& when (@luma > 0.5) {
background-color: lighten(@NavigationBar, 20%) !important;
}
// Bright Colors
& when (@luma <= 0.5) {
background-color: darken(@NavigationBar, 20%) !important;
}
}
// Open Button Group Hover Colors
.mixin-color-open-hover(){
// Dark Colors | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-10 | .mixin-color-open-hover(){
// Dark Colors
& when (@luma > 0.5) {
color: darken(contrast(@NavigationBar), 15%) !important;
}
// Bright Colors
& when (@luma <= 0.5) {
color: lighten(contrast(@NavigationBar), 15%) !important;
}
}
// Background/Foreground Dropdown Menu Hover
.mixin-background-foreground-dropdown-menu-hover(){
// Dark Colors
& when (@luma > 0.5) {
background-color: lighten(@NavigationBar, 15%) !important;
color: darken(contrast(@NavigationBar), 15%) !important;
.fa { | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-11 | .fa {
color: darken(contrast(@NavigationBar), 15%) !important;
}
}
// Bright Colors
& when (@luma <= 0.5) {
background-color: @NavigationBar !important;
color: lighten(contrast(@NavigationBar), 5%) !important;
.fa {
color: lighten(contrast(@NavigationBar), 5%) !important;
}
}
}
/**
* LESS Definitions
*/
// Nav Button Group
.module-list .megamenu > .dropdown .module-name{
.mixin-color;
}
// Home Button Caret
.navbar .megamenu > .dropdown.active .btn-group:not(.open).home .fa-caret-down, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-12 | // More Button Caret
.module-list .megamenu > .dropdown.more .fa,
// Module Toggle caret
.navbar .megamenu > .dropdown .btn-group > .dropdown-toggle .fa {
.mixin-fa-color;
}
// Nav Button Group Hover
.megamenu .dropdown .btn-group{
&:hover, &:focus{
.mixin-background-color-hover;
.btn,
> .dropdown-toggle .fa{
.mixin-color-hover;
}
}
}
// Active Button Group
.navbar .megamenu > .dropdown.active .btn-group{
.mixin-background-color-active;
> .dropdown-toggle .fa, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-13 | > .dropdown-toggle .fa,
> a.btn{
.mixin-fa-color;
}
}
// Active Button Group Hover
.navbar .megamenu > .dropdown.active .btn-group:hover{
.mixin-color-active-hover;
> .dropdown-toggle .fa,
> a.btn{
.mixin-color-active-hover;
}
}
// Open Nav Button Group
.navbar .megamenu > .dropdown .btn-group.open{
.mixin-background-color-open;
> .dropdown-toggle .fa,
> a.btn{
.mixin-fa-color;
}
}
// Open Nav Button Group Hover | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
2e0ca08a81a7-14 | }
}
// Open Nav Button Group Hover
.navbar .megamenu > .dropdown .btn-group.open:hover{
.mixin-color-open-hover;
> .dropdown-toggle .fa,
> a.btn{
.mixin-color-open-hover;
}
}
// Nav Button Group Dropdown Menu
.navbar .megamenu > .dropdown .dropdown-menu li a{
&:hover, &:focus{
.mixin-background-foreground-dropdown-menu-hover;
}
}
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Themes/index.html |
0a1103d5f1ae-0 | Email
Overview
Outlines the relationships between emails, email addresses, and bean records.
Email Tables
Table Name
Description
email_addresses
Each record in this table represents an email address in the system. Note that the invalid_email column and opt_out column are stored on this table, meaning that they are treated as properties of the email address itself, not a relationship attribute between a given email address and related record. This means if a Lead opts-out of a campaign, this email address will be considered opted-out in all contexts, not just with further correspondence with that specific Lead.
email_addr_bean_rel | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/index.html |
0a1103d5f1ae-1 | email_addr_bean_rel
The email_addr_bean_rel table maintains the relationship between the email address and its parent module record (Contacts, Accounts, Leads, Users, etc) to determine which record of the given module the email address belongs to. Note that this relationship table also has the primary_address and reply_to_address columns to indicate whether a given email address for a given record is the primary email address, the reply to email address, or some other address for the contact. A contact can have one address flagged as primary, and one flagged as "Reply To". This can be the same email address or two different email addresses.
emails_email_addr_rel | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/index.html |
0a1103d5f1ae-2 | emails_email_addr_rel
The emails_email_addr_rel table maintains the relationships between the email address and email records. Note that this relationship table also has the address_type column to indicate if the email address is related to the email as a "To", "From", "CC", or "BCC" address. The valid values at the database level for this column are: from, to, cc, bcc.
emails
Each record in this table represents an email in the system. Note that emails fall outside the scope of this document, but are mentioned here for clarity, as the two modules are closely related.
emails_beans
Similar to the email_addr_bean_rel table, the emails_beans table maintains the relationship between an email record and any related records (Contacts, Accounts, Cases, etc.).
<module> | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/index.html |
0a1103d5f1ae-3 | <module>
This is used to show how an email address record relates to a record in any module is set on bean_module. If bean_module is set to Contacts, <module> would be the contacts table.
The following diagram illustrates table relationships between email addresses and other modules, email addresses and email records, and email records and other modules.
Helper Queries
Retrieve the Primary Email Address of a Contact
The following query will fetch the email address given a specific contacts id:
SELECT
email_address
FROM email_addresses
JOIN email_addr_bean_rel eabr
ON eabr.email_address_id = email_addresses.id
WHERE eabr.bean_module = "Contacts"
AND eabr.bean_id = "<contact id>"
AND email_addresses.invalid_email = 0 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/index.html |
0a1103d5f1ae-4 | AND email_addresses.invalid_email = 0
AND eabr.deleted = 0
AND eabr.primary_address = 1;
Retrieve All Records Related to an Email Address
The following query will fetch the id and module name of all records related to the specified email address:
SELECT
bean_module,
bean_id
FROM email_addr_bean_rel eabr
JOIN email_addresses
ON eabr.email_address_id = email_addresses.id
WHERE email_addresses.email_address = "<email address>"
AND eabr.deleted = 0;
Retrieve All Emails Sent From An Email Address
The following query will fetch all emails sent from a specified email address:
SELECT
emails.name,
emails.date_sent
FROM emails | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/index.html |
0a1103d5f1ae-5 | SELECT
emails.name,
emails.date_sent
FROM emails
JOIN emails_email_addr_rel eear
ON eear.email_id = emails.id
JOIN email_addresses
ON eear.email_address_id = email_addresses.id
WHERE email_addresses.email_address = "<email address>"
AND eear.address_type = "from"
AND eear.deleted = 0
Cleanup Duplicate Email Addresses
The following queries will remove any duplicate email addresses.
 First, create a temporary table with distinct records from the email_addr_bean_rel table:
create table email_addr_bean_rel_tmp_ful
SELECT
*
FROM email_addr_bean_rel
WHERE deleted = '0' | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/index.html |
0a1103d5f1ae-6 | *
FROM email_addr_bean_rel
WHERE deleted = '0'
GROUP BY email_address_id,
bean_module,
bean_id
ORDER BY primary_address DESC;
Next, clear out the email_addr_bean_rel table:
truncate email_addr_bean_rel;
Move the records from the temporary table back to email_addr_bean_rel:
INSERT INTO email_addr_bean_rel
SELECT
*
FROM email_addr_bean_rel_tmp;
Validate that all of the duplicates have been removed:
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 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/index.html |
0a1103d5f1ae-7 | GROUP BY bean_id,
bean_module,
email_address_id
HAVING repetitions > 1;
Finally, remove the temporary table:
drop table email_addr_bean_rel_tmp;
Email Address Validation
Sugar validates emails addresses according to the RFC 5321 and RFC 5322 standards. The following sections will detail how a developer can validate email addresses both server and client side.
Server Side
To validate an email address in a server-side context, the EmailAddress::isValidEmail() static method should be used. For example:
$emailAddress = "[email protected]";
$isValid = EmailAddress::isValidEmail($emailAddress); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/index.html |
0a1103d5f1ae-8 | $isValid = EmailAddress::isValidEmail($emailAddress);
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.
Client Side
To validate an email address client-side context, the app.utils.isValidEmailAddress() function can be used.
var emailAddress = "[email protected]";
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. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/index.html |
0a1103d5f1ae-9 | TopicsMailer FactoryThe Mailer Factory, located in ./modules/Mailer/MailerFactory.php, helps developers generate outbound mailers for the system account as well as individual user accounts. The Mailer Factory is a replacement for SugarPHPMailer which is now deprecated.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/index.html |
d54a59dfd65b-0 | Mailer Factory
Overview
The Mailer Factory, located in ./modules/Mailer/MailerFactory.php, helps developers generate outbound mailers for the system account as well as individual user accounts. The Mailer Factory is a replacement for SugarPHPMailer which is now deprecated.
Mailers
There are two types of outbound mailers: System and User. The follow sections will outline how to use each.
System Mailer
The system outbound mailer can be set using the getSystemDefaultMailer method. This will set the mailer to use the system outbound email account.Â
Example
$mailer = MailerFactory::getSystemDefaultMailer();
User Mailer | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/Mailer_Factory/index.html |
d54a59dfd65b-1 | $mailer = MailerFactory::getSystemDefaultMailer();
User Mailer
The user outbound mailer can be set using the getMailerForUser method. This will set the mailer to use the outbound email account for a specific user.Â
Example
$user = BeanFactory::getBean("Users", 1);
$mailer = MailerFactory::getMailerForUser($user);
Populating the Mailer
Setting the Subject
To set the email subject, use the setSubject method. It accepts a plain text string.
Example
$mailer->setSubject("Test Mail Subject");
Setting the Body
Depending on your email type, you can use the setTextBody and/or setHtmlBody methods respectively to populate the content of the email body.
Example
// Text Body | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/Mailer_Factory/index.html |
d54a59dfd65b-2 | Example
// Text Body
$mailer->setTextBody("This is a text body message");
// HTML Body
$mailer->setHtmlBody("This is an <b>HTML</b> body message. <br> You can use html tags.");
Note:Â The email HTML body is not necessary if you have populated the text body.
Adding Recipients
To add recipients to your email, you can use the addRecipientsTo, addRecipientsCc, or addRecipientsBcc methods . These methods require an EmailIdentity object as a parameter.
Example
$mailer->addRecipientsTo(new EmailIdentity('[email protected]', 'User 1'));
$mailer->addRecipientsCc(new EmailIdentity('[email protected]', 'User 2')); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/Mailer_Factory/index.html |
d54a59dfd65b-3 | $mailer->addRecipientsBcc(new EmailIdentity('[email protected]', 'User 3'));
Clearing Recipients
You can clear the current recipients specified in the mailer by using the clearRecipients method.
Example
$to = true;
$cc = true;
$bcc = true;
$mailer->clearRecipients($to, $cc, $bcc);
Adding Attachments
To add attachments, use the addAttachment method.
Example
$path = "/path/to/your/document";
$mailer->addAttachment(new Attachment($path));
Sending Emails | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/Mailer_Factory/index.html |
d54a59dfd65b-4 | $mailer->addAttachment(new Attachment($path));
Sending Emails
Once your email is populated, you can send it using the send method. The send method will return the content of the mail. If the Mailer Factory experiences an error, it will throw an exception. It is highly recommended to use a try and catch when sending emails.
Example
$mailSubject = "Test Mail Subject";
$mailHTML = "<h1>SugarCRM</h1><br> Test body message";
$mailTo = array(
0 => array(
'name' => 'Test User',
'email' => '[email protected]',
),
1 => array(
'name' => 'Other Recipient',
'email' => 'email@addres'
)
); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/Mailer_Factory/index.html |
d54a59dfd65b-5 | 'email' => 'email@addres'
)
);
$mailAttachment = "/path/to/pdf/files/document.pdf";
try {
$mailer = MailerFactory::getSystemDefaultMailer();
$mailTransmissionProtocol = $mailer->getMailTransmissionProtocol();
$mailer->setSubject($mailSubject);
$body = trim($mailHTML);
$textOnly = EmailFormatter::isTextOnly($body);
if ($textOnly) {
$mailer->setTextBody($body);
} else {
$textBody = strip_tags(br2nl($body)); // need to create the plain-text part
$mailer->setTextBody($textBody);
$mailer->setHtmlBody($body);
} | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/Mailer_Factory/index.html |
d54a59dfd65b-6 | $mailer->setHtmlBody($body);
}
$mailer->clearRecipients();
foreach ($mailTo as $mailTo) {
$mailer->addRecipientsTo(new \EmailIdentity($mailTo['email'], $mailTo['name']));
}
$mailer->addAttachment(new \Attachment($mailAttachment));
$result = $mailer->send();
if ($result) {
// $result will be the body of the sent email
} else {
// an exception will have been thrown
}
} catch (MailerException $me) {
$message = $me->getMessage();
switch ($me->getCode()) {
case \MailerException::FailedToConnectToRemoteServer: | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/Mailer_Factory/index.html |
d54a59dfd65b-7 | case \MailerException::FailedToConnectToRemoteServer:
$GLOBALS["log"]->fatal("BeanUpdatesMailer :: error sending email, system smtp server is not set");
break;
default:
$GLOBALS["log"]->fatal("BeanUpdatesMailer :: error sending e-mail (method: {$mailTransmissionProtocol}), (error: {$message})");
break;
}
}
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Email/Mailer_Factory/index.html |
c8e5f6fb5ba4-0 | Logic Hooks
Overview
The Logic Hook framework allows you to append actions to system events such as when creating, editing, and deleting records.
Hook Definitions
A logic hook definition file defines the various actions to execute when an event is triggered. It is important to note that there are various ways to implement a logic hook. The following sections describe the different ways to implement a logic hook and when to use each.
Methodologies
Logic hook definitions can pertain to a specific module or to the entire application. Either way, you must decide if the logic hook definition will be implemented as an extension of or directly to the module or application. The following sections explain the difference between these methodologies.
Module Extension Hooks | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
c8e5f6fb5ba4-1 | Module Extension Hooks
Module extension hooks are located in ./custom/Extension/modules/<module>/Ext/LogicHooks/ and allow a developer to define hook actions that will be executed for the specified events in a given module. Extensions are best used when creating customizations that may be installed in various environments. They help prevent conflicting edits that occur when modifying ./custom/modules/<module>/logic_hooks.php. More information can be found in the Logic Hooks extension section.
Module Hooks | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
c8e5f6fb5ba4-2 | Module Hooks
Module hooks are located in ./custom/modules/<module>/logic_hooks.php and allow a developer to define hook actions that will be executed for the specified events in a given module. This path can be used for private development, however, it is not recommended for use with distributed modules and plugins. For distributed code, please refer to using module extensions.
Application Extension Hooks
Application extension hooks are located in ./custom/Extension/application/Ext/LogicHooks/ and allow a developer to define hook actions that will be executed for all specified application-level events using the extension framework. More information can be found in the Logic Hooks extension section.
Application Hooks | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
c8e5f6fb5ba4-3 | Application Hooks
Application hooks are located in ./custom/modules/logic_hooks.php and allow a developer to define hook actions that will be executed for the specified events in all modules. This path can be used for private development, however, it is not recommended for use with distributed modules and plugins. For distributed code, please refer to using application extensions.
Definition Properties
All logic hooks must have a $hook_version and $hook_array variable defined. The following sections cover each required variable.
hook_version
All logic hook definitions will define a $hook_version. This determines the version of the logic hook framework. Currently, the only supported hook version is 1.
$hook_version = 1;
hook_array | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
c8e5f6fb5ba4-4 | $hook_version = 1;
hook_array
The logic hook definition will also contain a $hook_array. This defines the specific action to execute. The hook array will be defined as follows:
Name
Type
Description
event_name
String
The name of the event to append the action to
process_index
Integer
The order of action execution
description
String
A short description of the hook action
file_path
String
The path to the logic hook file in the ./custom/ directory, or null if using namespaces
class_name
String
The name of the logic hook action class including any namespaces
method_name
String
The name of the logic hook action method
Your definition should resemble the code block below:
<?php
$hook_version = 1;
$hook_array['<event_name>'][] = array( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
c8e5f6fb5ba4-5 | $hook_array['<event_name>'][] = array(
<process_index>, //Integer
'<description>', //String
'<file_path>', //String or null if using namespaces
'<class_name>', //String
'<method_name>', //String
);
Hook Method
The hook action class can be located anywhere you choose. We recommended grouping the hooks with the module they are associated with in the ./custom/ directory. You can create a hook action method either with a namespace or without.
Namespaced Hooks
As of 7.7, developers can create namespaced logic hooks. When using namespaces, the file path in ./custom/Â will be automatically built out when using the corresponding namespace. The filename defining the class must match the class name exactly to allow the autoloader to find the class definition. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
c8e5f6fb5ba4-6 | Namespace
File Path
Sugarcrm\Sugarcrm\custom
./custom/
Sugarcrm\Sugarcrm\custom
./custom/src/
Sugarcrm\Sugarcrm\custom\any\path
./custom/any/path/
Sugarcrm\Sugarcrm\custom\any\path
./custom/src/any/path/
./custom/Extension/modules/Accounts/Ext/LogicHooks/<file>.php
<?php
$hook_array['before_save'][] = array(
1,
'Hook description',
null,
'Sugarcrm\\Sugarcrm\\custom\\modules\\Accounts\\className',
'methodName'
);
?>
./custom/modules/Accounts/className.php
<?php | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
c8e5f6fb5ba4-7 | ?>
./custom/modules/Accounts/className.php
<?php
namespace Sugarcrm\Sugarcrm\custom\modules\Accounts;
class className
{
function methodName($bean, $event, $arguments)
{
//logic
}
}
?>
The logic hook method signature may contain different arguments depending on the hook event you have selected.
Hooks without Namespaces
./custom/Extension/modules/Accounts/Ext/LogicHooks/<file>.php
<?php
$hook_array['before_save'][] = array(
1,
'Hook description',
'custom/modules/Accounts/customLogicHook.php',
'className',
'methodName'
);
?> | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
c8e5f6fb5ba4-8 | 'className',
'methodName'
);
?>
./custom/modules/Accounts/customLogicHook.php
<?php
class className
{
function methodName($bean, $event, $arguments)
{
//logic
}
}
?>
The logic hook method signature may contain different arguments depending on the hook event you have selected.
Considerations
When using logic hooks, keep in mind the following best practices:
As of PHP 5.3, objects are automatically passed by reference. When creating logic hook signatures, do not append the ampersand (&) to the $bean variable. Doing this will cause unexpected behavior.
There is no hook that fires specifically for the ListView, DetailView or EditView events. Instead, use either the process_record or after_retrieve logic hooks. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
c8e5f6fb5ba4-9 | In order to compare new values with previous values, use fetched_row to determine whether a change has occurred: if ($bean->fetched_row['{field}'] != $bean->{field})
{
//logic
}
Make sure that the permissions on the logic_hooks.php file and the class file that it references are readable by the web server. Otherwise, Sugar will not read the files and your business logic extensions will not work. For example, *nix developers who are extending the Tasks logic should use the following command for the logic_hooks file and the same command for the class file that will be called:
chmod +r ./custom/modules/Tasks/logic_hooks.php
Make sure that the entire ./custom/ directory is writable by the web server or else the logic hooks code will not work properly. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
c8e5f6fb5ba4-10 | TopicsApplication HooksApplication hooks execute logic when working with the global application.Module HooksModule hooks execute logic when working with Sugar modules (e.g. Accounts, Cases, etc.).User HooksUser hooks execute logic around user actions such as logging in and logging out.Job Queue HooksJob Queue hooks execute logic when working with the Job Queue module.SNIP HooksSNIP hooks execute logic when working with the SNIP email-archiving service.API HooksAPI hooks execute logic when working with the REST API and routing.Web Logic HooksWeb logic hooks let administrators post record and event information to a specified URL when certain sugar events take place.Logic Hook Release NotesThis page documents historical changes to Sugar's logic hook libraries.
Last modified: 2023-02-03 21:04:03 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/index.html |
9da027f1c82b-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 |
3992a21d4e38-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(); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Job_Queue_Hooks/job_failure_retry/index.html |
3992a21d4e38-1 | $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'
);
?> | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Job_Queue_Hooks/job_failure_retry/index.html |
3992a21d4e38-2 | '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 |
f478eb88b177-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, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Job_Queue_Hooks/job_failure/index.html |
f478eb88b177-1 | //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
{ | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Job_Queue_Hooks/job_failure/index.html |
f478eb88b177-2 | 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 |
a85c05905f8d-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 |
ac900372c464-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, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/after_logout/index.html |
ac900372c464-1 | //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
} | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/after_logout/index.html |
ac900372c464-2 | {
//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 |
bc9a44809fe2-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. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/login_failed/index.html |
bc9a44809fe2-1 | 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
}
}
?>
 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/login_failed/index.html |
bc9a44809fe2-2 | {
//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 |
e5529b0eb6fa-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. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/after_login/index.html |
e5529b0eb6fa-1 | 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
}
}
?> | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/after_login/index.html |
e5529b0eb6fa-2 | {
//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 |
1a366bce5d7f-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, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/before_logout/index.html |
1a366bce5d7f-1 | //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
} | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/User_Hooks/before_logout/index.html |
1a366bce5d7f-2 | {
//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 |
36b300432a02-0 | Application Hooks
Application hooks execute logic when working with the global application. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/index.html |
36b300432a02-1 | 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 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/index.html |
36b300432a02-2 | 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. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/index.html |
36b300432a02-3 | 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 |
d5c382f90a83-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 |
030aa6032f42-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 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/server_round_trip/index.html |
030aa6032f42-1 | 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', | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/server_round_trip/index.html |
030aa6032f42-2 | '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
{
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 |
cb5c265bdb40-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 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_entry_point/index.html |
cb5c265bdb40-1 | 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', | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_entry_point/index.html |
cb5c265bdb40-2 | '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
{
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 |
c3ccc61e3675-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( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/handle_exception/index.html |
c3ccc61e3675-1 | $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
{ | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/handle_exception/index.html |
c3ccc61e3675-2 | 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 |
aa14df4b3965-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. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_ui_frame/index.html |
aa14df4b3965-1 | 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(); | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_ui_frame/index.html |
aa14df4b3965-2 | $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',
//The method to call.
'after_ui_frame_method'
);
?>
./custom/modules/<module>/logic_hooks_class.php
<?php | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_ui_frame/index.html |
aa14df4b3965-3 | <?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, | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_ui_frame/index.html |
aa14df4b3965-4 | //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
} | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_ui_frame/index.html |
aa14df4b3965-5 | {
//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 |
402e93e4d031-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( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_session_start/index.html |
402e93e4d031-1 | $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
{ | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_session_start/index.html |
402e93e4d031-2 | 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 |
6be75139730e-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 | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/entry_point_variables_setting/index.html |
6be75139730e-1 | 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. | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/entry_point_variables_setting/index.html |
6be75139730e-2 | '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
}
}
?>
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 |
1d880147eadc-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( | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_load_user/index.html |
1d880147eadc-1 | $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
{ | https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Logic_Hooks/Application_Hooks/after_load_user/index.html |
1d880147eadc-2 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.