Results 1 to 4 of 4

Thread: How to change Modified_by_Userid when Deleting Contact

  1. #1
    aram is offline Sugar Community Member
    Join Date
    Aug 2004
    Posts
    52

    Default How to change Modified_by_Userid when Deleting Contact

    We only allow certain employees the right to delete Contacts.
    However, we've had Contacts deleted that should not have been
    and we need to track down who deleted them.
    The Modified_by UserID shows only the last person that modified
    a phone number or similar field, not the user logged in while doing the delete action.

    Where (and how) can we modify the code so a Delete Contact action gets stamped
    with the actual logged in user who did the delete?
    Version 5.0.0a php 5.2.6

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: How to change Modified_by_Userid when Deleting Contact

    Not upgrade safe but you could alter the query if you'd like in data/SugarBean.php:

    PHP Code:
        function mark_deleted($id)
        {

            
    $date_modified gmdate('Y-m-d H:i:s');
            if(isset(
    $_SESSION['show_deleted']))
            {
                
    $this->mark_undeleted($id);
            }
            else
            {
                
    // call the custom business logic
                
    $custom_logic_arguments['id'] = $id;
                
    $this->call_custom_logic("before_delete"$custom_logic_arguments);
                            global 
    $current_user

                
    $query "UPDATE $this->table_name set deleted=1 , date_modified = '$date_modified', modified_user_id = '$current_user->id'' where id='$id'";
                
    $this->db->query($querytrue,"Error marking record deleted: ");
                
    $this->mark_relationships_deleted($id);

                
    // Take the item off the recently viewed lists
                
    $tracker = new Tracker();
                
    $tracker->makeInvisibleForAll($id);

                
    // call the custom business logic
                
    $this->call_custom_logic("after_delete"$custom_logic_arguments);
            }
        } 

  3. #3
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: How to change Modified_by_Userid when Deleting Contact

    Hi guys

    Alternatively you can create a custom controller and implement the method action_delete.
    Inside this method you can change the modified_user_id.

    Regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  4. #4
    aram is offline Sugar Community Member
    Join Date
    Aug 2004
    Posts
    52

    Default Re: How to change Modified_by_Userid when Deleting Contact

    I modified sugarbean.php as described and that does what I needed...! ! !

    I did have to remove the one extra quote mark in your code shown below to get it working:
    '$current_user->id' '

    Thanks very much for the help...

    Aram
    Last edited by aram; 2008-11-22 at 02:38 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Duplicate Contact on Account change
    By ppolkinghorne in forum Help
    Replies: 5
    Last Post: 2011-09-06, 02:07 PM
  2. How to change field in New Contact
    By tommyfan in forum Help
    Replies: 2
    Last Post: 2006-10-18, 03:18 PM
  3. Contact list sort option change
    By u694283 in forum Help
    Replies: 0
    Last Post: 2006-04-19, 12:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •