Under Review

Ability to track who deleted records in audit table

It would be great to have the ability to see in the audit table who deleted record and when, AND once it's been restored back from the soft-delete, link back the orphaned records. (related records in subpanels need to be edit/saved after restoring the deleted record in order to be displayed again)

It's been difficult not being able to blame someone in particular 

  • Yes, the effort to restore records can be very high.

    You just have to search for all linked records which were deleted.

    And perhaps the linked records had been deleted in the meantime too.

    All in all a job which asks for manual interaction.

    When I was operating such a  system I had the issue that somebody merged everything from about 100 accounts to one single HQ account and deleted the 99 other accounts. Later he recognized that the idea was not the best idea of his life. Took me a lot of time to restore the original relationship network.

  • This works great Harald!,

    Thanks for the suggestion. 

    The only thing is that after restoring the record, the "orphaned" records need to be edit/saved in order to recover the linkage between them and the deleted record. 

    Regards, 

    Angel M.

  • I am using Trash Bin For my Sugar CRM.  It's an advanced tool that allows you to keep track of deleted/restored records along with the reason for its deletion/restoration. ? Trash Bin acts as an archive for all your deleted records from the CRM and helps users to restore them when required.

  • In a former life I used logic_hooks to track record deletions in the audit table of modules.

    Just can use the before_delete event and write an own record to the audit table.

    Here my code (adapted to version 8.x):

    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class ClassLeadsVerify {

        function LeadCheck(SugarBean &$focus, $event, $arguments) {

            if ($event=="before_delete") {
                $GLOBALS['log']->info("delete Lead ID:".$focus->id);
                   global $current_user;
                $killer = $current_user->id;
                $query = "INSERT INTO leads_audit (id,parent_id,date_created,created_by,field_name,data_type,before_value_string,after_value_string) ".
                         "VALUES (uuid(),'$focus->id',now(),'$killer','deleted','bool','0','1');";
                $GLOBALS['db']->query($query);               
             }
         
        }
    }
    ?>
  • I'm not sure if this will solve your problem entirely, but whenever this has happened to us, I just call customer service and they are able to tell me the answer instantly.  Obviously this is for on-demand instances.