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');
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
}
}
?>