Dear Fellow Developers,
I need the functionality to large number of targets to leads.
I have attempted to follow the instructions given at URL: https://developer.sugarcrm.com/2013/02/26/mass-convert-targets-to-leads/
First, I created the a drodown with possible values of : Yes, No, or blank in Targets module and enabled mass update for this.
Also added the following code to lookhooks.php:
<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'Mass Convert Prospects into Leads', 'custom/modules/Prospects/convertIntoLeads.php','convertIntoLeadsC', 'convertIntoLeadsF');
?>
Then added the following code in SuiteCRM>custom>Prospects>convertIntoLeads.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class convertIntoLeadsC
{
function convertIntoLeadsF($bean, $event, $args)
{
if (isset($bean->convert_to_lead_c) && $bean->convert_to_lead_c != $bean->fetched_row['convert_to_lead_c'] && empty($bean->lead_id))
{
$oLead = new Lead();
foreach ($oLead->field_defs as $keyField => $aFieldName) {
$oLead->$keyField = $bean->$keyField;
}
$oLead->id = '';
$oLead->save(true);
$bean->lead_id = $oLead->id;
}
}
}
But this set of instruction is not working.
Can some intelligent developer help me to achieve this functionality?
With thanks,
RK