What I’m trying to do is have a “referer” for the lead which is a contact. When I convert the a lead to a contact, I want the lead the relationship Lead → referrer (one to many leads_contacts) to move over to Contacts → Opportunities (one to Many). In the past I’ve added to a custom view.convertlead.php (around line 431) this:
$lead->load_relationship('contacts_leads_1');
$coopProspects = $lead->contacts_leads_1->getBeans();
$coopProspect = reset($coopProspects);
$beans[$module]->load_relationship('contacts_opportunities_2');
$beans[$module]->contacts_opportunities_2->add($coopProspect);
and it has worked just fine. And it does (in this case) as long as I don’t create a contact, but instead select one on conversion. If I create one in the conversion process (not the contact the lead is related to, but creating a contact from the lead). It errors out. I’ve been staring at the error message for like 2 days and I just can’t figure out what’s going on. It’s probably so simple, but I’ve been looking at it too long. Anyone see what’s going on here?
Here’s the error I’m getting on convert:
Notice: Undefined property: Account::$contacts_opportunities_2 in /home/crm/public_html/custom/modules/Leads/views/view.convertlead.php on line 442
Fatal error: Uncaught Error: Call to a member function add() on null in /home/crm/public_html/custom/modules/Leads/views/view.convertlead.php:442 Stack trace: #0 /home/crm/public_html/custom/modules/Leads/views/view.convertlead.php(77): ViewConvertLead->handleSave() #1 /home/crm/public_html/include/MVC/View/SugarView.php(210): ViewConvertLead->display() #2 /home/crm/public_html/include/MVC/Controller/SugarController.php(432): SugarView->process() #3 /home/crm/public_html/include/MVC/Controller/SugarController.php(363): SugarController->processView() #4 /home/crm/public_html/include/MVC/SugarApplication.php(101): SugarController->execute() #5 /home/crm/public_html/index.php(52): SugarApplication->execute() #6 {main} thrown in /home/crm/public_html/custom/modules/Leads/views/view.convertlead.php on line 442
I still am pretty new to working with beans, and don’t 100% get it yet, so I’m sure I’m missing something fundamental. Please help!
Note: line 442 is the last line.