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');
class before_relationship_add_class
{
function before_relationship_add($bean, $event, $arguments)
{
//logic
}
}
?>