I have a one to may relationship between leads/contacts and a custom module, so i have a sub panel showing on both leads and contacts, when i convert the lead, the relationship information isn’t converted, I have tried the following code and I hit a white page nothing seems to happen, in the log i can see the relationship load but thats all that happens with it,
I got the PDL_groan and pdl_groan from the Table and Object name in the module folder.
<?php
class DataTransfer
{
function doDataTransfer($bean, $events, $arguments)
{
$action = $_REQUEST['action'];
if ($action == 'ConvertLead') //Must confirm it only triggers on conversion!!
{
$lead_id = $bean->id;
$contact_id = $bean->contact_id;
$bean->load_relationship('pdl_groan_leads');
//Remove relationship
$pdl_groan = array();
foreach ($bean->pdl_paydayloan->getBeans() as $PDL_groan)
{
$PDL_groan_id = $PDL_groan->id;
$pdl_groan[] = $PDL_groan_id;
$bean->pdl_groan->delete($lead_id, $PDL_groan_id);
}
$bean->save();
//Transfer relationship to Contact record
$contact = new Contact();
$contact->retrieve($contact_id);
$contact->load_relationship('pdl_groan_contacts');
foreach ($pdl_groan as $PDL_groan)
{
$contact->pdl_groan->add($PDL_groan);
}
}
}
}
?>
Would someone please be able to help with this. thanks
You can also try to set up XDEBUG and an IDE, so all of these things become more transparent to you… that would surely help you find the problem with your logic hook (from looking at it, I can’t find any, although I am not sure about whether some of the things you tried work or not).
I have resolved the first half of the code where it removes it from the lead not sure what i did, tried renaming the relationship and beans and must have gotten the right comination, but then the second half doesnt work, i now get the same error on line 34.
now I have
<?php
class DataTransfer
{
function doDataTransfer($bean, $events, $arguments)
{
$action = $_REQUEST['action'];
if ($action == 'ConvertLead') //Must confirm it only triggers on conversion!!
{
$lead_id = $bean->id;
$contact_id = $bean->contact_id;
$bean->load_relationship('pdl_groan_leads');
//Remove relationship
$pdl_groan = array();
foreach ($bean->pdl_groan_leads->getBeans() as $PDL_groan)
{
$PDL_groan_id = $PDL_groan->id;
$pdl_groan[] = $PDL_groan_id;
$bean->pdl_groan->delete($lead_id, $PDL_groan_id);
}
$bean->save();
//Transfer relationship to Contact record
$contact = new Contact();
$contact->retrieve($contact_id);
$contact->load_relationship('pdl_groan_contacts');
foreach ($pdl_groan as $PDL_groan)
{
$contact->pdl_groan->add($PDL_groan);
}
}
}
}
?>
Thanks PGR, i will be doing, however i can’t do anything untill 20:30hrs, people are using the system right now, i seem a solution to do it via workflow, although with that i can’t work out how to trigger the flow on lead convert go figure.
i sorted it, this instance or crm was missing the Converted option from the Status dropdown, therefore it wasn’t getting changed, comparing it with another instance i have, which i seemingly have never had any issues with, I added the converted option back in, now when the lead converts that field is changed, and now the workflow runs,