Create "after save" logic hook in SuiteCRM for last activity date in list view while Creating/Editing Task in targets details view.
Adding your own logic hooks This involves creating a file in custom/Extension/application/Ext/LogicHooks/ for application hooks and custom/Extension/modules/<TheModule>/Ext/LogicHooks/ for module specific hooks. These files can then add to/alter the $hook_array as appropriate.
A logic hook definition file defines the various actions to execute when an event is triggered. It is important to note that there are various ways to implement a logic hook. The following sections describe the different ways to implement a logic hook and when to use each.
Create a field as last_activate_date in Targets module or your module through Admin > Studio > Targets > Fields.
It will created in prospects_cstm table as last_activity_date_c.
Add the code in custom/modules/Tasks/logic_hooks.php. If logic_hooks.php doesn't exit create logic_hook.php.
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(
78,
'Retrieve and compare values',
'custom/modules/Tasks/lastActiveDate.php',
'lastActiveDate',
'after_save_method'
);
Then create lastActiveDate.php and add the following code:
Class name and file name must be same.
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class lastActiveDate
{
function after_save_method($bean, $event, $arguments)
{
$module=$bean->parent_type;
$record_id=$bean->parent_id;
$bean1 = BeanFactory::getBean($module, $record_id);
$tblname = $bean1->table_name;
$tblname_cstm = $tblname."_cstm";
$bean->db->query("UPDATE ".$tblname_cstm." SET last_activity_date_c=now() WHERE id_c='".$bean1->id."'");
}
}
last activities date and time will stored in last_activity_date_c feild, while creating and modifying the Tasks.
Then go to Admin > Studio > Targets > Layouts > ListView click and drag Last Activity Date from hidden to default.
It will appear in listView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With