5

Create "after save" logic hook in SuiteCRM for last activity date in list view while Creating/Editing Task in targets details view.

Star
  • 3,222
  • 5
  • 32
  • 48
vinsonjebasingh
  • 311
  • 3
  • 11

1 Answers1

6

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.

vinsonjebasingh
  • 311
  • 3
  • 11