I added a custom module named locations to the convert lead layout. I am trying to make an after save logic hook to create the relationship between contacts and opportunities.
The locations module has a one to many relationship with contacts and opportunities.
I am able to make a logic hook that creates the relationship with a hardcoding location ID, but I am having trouble dynamically getting the location ID to create the relationship.
In my methodology there are three scenarios that play out when using the lead conversion tool
1) I have a workflow that creates a location automatically when an account is created. It takes the Account name and Billing Address and copies them into the Location name and Shipping Address. So if an account is created while using the Lead Conversion tool then you do not enter anything into the Location section of the tool.
2) If an account already exists then when you use the lead conversion tool you select the Account from the Accounts list and the billing information fills in automatically. Then you fill in the name and any other information you may have
3)The account and location both already exist and you just select them from the list
Here is the code I am using to try and create the relationship between the location and opportunity:
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
function updateOpportunity($bean, $event, $arguments)
if($_REQUEST['action'] != 'ConvertLead')
$location = BeanFactory::getBean('Locations', $id);
$rel_name = 'gh1_location_opportunities';
#$record_id = '7c02eca0-91dc-11e8-b606-027a430c0995#';
$record_id = $location->id;
This is my very first adventure into Sugar Development and I have some exposure to PHP, but nothing crazy. Any Help?