Anyone know how to edit lead list view so one of the columns has a button or link that you can click on to convert the lead to an opportunity instead of having to go into detail view and do it?
Anyone know how to edit lead list view so one of the columns has a button or link that you can click on to convert the lead to an opportunity instead of having to go into detail view and do it?
Hi Jeff,
There are probably a few ways you could do this, but here's the way I was able to get it working. First, create a custom TextField (I named mine "Convert Link"). Then, create two logic hooks. Here is my custom/modules/Leads/logic_hooks.php file:
<?php $hook_version = 1; $hook_array = Array(); $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array(1, 'Populate Convert Link', 'custom/modules/Leads/LeadsLogicHooks.php', 'LeadsLogicHooks', 'before_save_method'); $hook_array['process_record'][] = Array(1, 'Format Convert Link', 'custom/modules/Leads/LeadsLogicHooks.php', 'LeadsLogicHooks', 'process_record_method');
And here is my custom/modules/Leads/LeadsLogicHooks.php file:
<?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class LeadsLogicHooks { function before_save_method($bean, $event, $arguments) { if(empty($bean->convert_link_c)) { // Replace {site_url} with the actual URL to your Sugar instance $bean->convert_link_c = 'http://{site_url}/index.php?module=Leads&action=ConvertLead&record=' . $bean->id; } } function process_record_method($bean, $event, $arguments) { if(!empty($bean->convert_link_c)) { $bean->convert_link_c = '<a href="' . $bean->convert_link_c . '">Convert</a>'; } } }
Note that the Convert link won't show up for existing Leads until they have been saved (allowing the before_save logic hook to run), but all new Leads should have it show up right away. I hope that helps!
-Alan
My logic_hooks.php file already has similar code in it for another function and says the file will be rebuilt? (I am running CE version, actually SuiteCRM fork)
// 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, 'Leads push feed', 'modules/Leads/SugarFeeds/LeadFeed.php','LeadFeed', 'pushFeed');
$hook_array['before_save'][] = Array(77, 'updateGeocodeInfo', 'modules/Leads/LeadsJjwg_MapsLogicHook.php','LeadsJjwg_MapsLogicHook', 'updateGeocodeInfo');
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(77, 'updateRelatedMeetingsGeocodeInfo', 'modules/Leads/LeadsJjwg_MapsLogicHook.php','LeadsJjwg_MapsLogicHook', 'updateRelatedMeeti$
Hi Jeff,
You are right - the proper way to add the logic hook would be to create a file here: ./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php
This would just contain the one line (per logic hook) where the $hook_array is defined (for example, lines 5-6 of my example code above). Then you can run a Quick Repair and have it automatically added to the logic_hooks.php file. I hope that helps!
-Alan
I had to add a couple new links and realized there is no real reason to store the link in the actual field in the database.
In logic_hooks.php just remove the before_save array lines and remove the before_save_method function from LeadsLogicHooks
In the process_record_method just have in generate the entire HTML code including the link tag