Results 1 to 8 of 8

Thread: Sometimes 2 of a message in Sent Mail list

  1. #1
    rogersugarsugar is offline Sugar Community Member
    Join Date
    Jun 2007
    Posts
    38

    Default Sometimes 2 of a message in Sent Mail list

    BitRock 4.5.1.e

    This doesn't seem to happen for all sent messages, but for some, there are duplicates listed.

    The inconsistency is a bit troubling - I'm afraid to delete one of a duplicate in case there's actually only one copy stored, and have the process delete that only copy. ** Okay, I just did a test message, two showed up in Sent Email, I deleted one copy, and both are gone **

    Why is this happening? What, exactly, is happening? How should I deal with it?

    Thanks.
    Last edited by rogersugarsugar; 2007-07-18 at 04:40 PM.

  2. #2
    swilliams is offline Sugar Community Member
    Join Date
    Apr 2007
    Posts
    21

    Default Re: Sometimes 2 of a message in Sent Mail list

    Don't know if this is your problem or not, but I was having duplicates if I associated the email to a contact, and then selected that contact to send the email to.

    I found an error in modules/Email/Save.php . It was making duplicate entries in email_contact which causes the listview query to return multiple rows for a single email.

    The problem is in the section of code below. It is checking against $exContactIds to make sure it doesn't create duplicates. But, $exContactIds is not created until the last code block below.

    Code:
    if(isset($_REQUEST['object_type']) && !empty($_REQUEST['object_type']) && isset($_REQUEST['object_id']) && !empty($_REQUEST['object_id'])) {
        //run linking code only if the object_id has not been linked as part of the contacts above
        $GLOBALS['log']->debug("CESELY".$_REQUEST['object_type']);
        if(!in_array($_REQUEST['object_id'],$exContactIds)){
            $rel = strtolower($_REQUEST['object_type']);
            $focus->load_relationship($rel);
            $focus->$rel->add($_REQUEST['object_id']);
            $GLOBALS['log']->debug("CESELY LOADED".$_REQUEST['object_type']);
        }
    }
    //// handle legacy parent_id/parent_type relationship calls
    elseif(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
        //run linking code only if the object_id has not been linked as part of the contacts above
        if(!in_array($_REQUEST['parent_id'],$exContactIds)){
            $rel = strtolower($_REQUEST['parent_type']);
            $focus->load_relationship($rel);
            $focus->$rel->add($_REQUEST['parent_id']);
        }
    }
    
    ////    END RELATIONSHIP LINKING
    ///////////////////////////////////////////////////////////////////////////////
    $focus->save(FALSE);
    ////	END EMAIL SAVE/SEND SETUP
    ///////////////////////////////////////////////////////////////////////////////
    
    
    
    ///////////////////////////////////////////////////////////////////////////////
    ////	RELATIONSHIP LINKING
    $focus->load_relationship('users');
    $focus->users->add($current_user->id);
    
    if(!empty($_REQUEST['to_addrs_ids'])) {
    	$focus->load_relationship('contacts');
    	$exContactIds = explode(';', $_REQUEST['to_addrs_ids']);
    	foreach($exContactIds as $contactId) {
    		$contactId = trim($contactId);
    		$focus->contacts->add($contactId);
    	}
    }


    Change the order to:

    Code:
    if(!empty($_REQUEST['to_addrs_ids'])) {
    	$focus->load_relationship('contacts');
    	$exContactIds = explode(';', $_REQUEST['to_addrs_ids']);
    	foreach($exContactIds as $contactId) {
    		$contactId = trim($contactId);
    		$focus->contacts->add($contactId);
    	}
    }
    
    if(isset($_REQUEST['object_type']) && !empty($_REQUEST['object_type']) && isset($_REQUEST['object_id']) && !empty($_REQUEST['object_id'])) {
        //run linking code only if the object_id has not been linked as part of the contacts above
        $GLOBALS['log']->debug("CESELY".$_REQUEST['object_type']);
        if(!in_array($_REQUEST['object_id'],$exContactIds)){
            $rel = strtolower($_REQUEST['object_type']);
            $focus->load_relationship($rel);
            $focus->$rel->add($_REQUEST['object_id']);
            $GLOBALS['log']->debug("CESELY LOADED".$_REQUEST['object_type']);
        }
    }
    //// handle legacy parent_id/parent_type relationship calls
    elseif(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
        //run linking code only if the object_id has not been linked as part of the contacts above
        if(!in_array($_REQUEST['parent_id'],$exContactIds)){
            $rel = strtolower($_REQUEST['parent_type']);
            $focus->load_relationship($rel);
            $focus->$rel->add($_REQUEST['parent_id']);
        }
    }
    ////    END RELATIONSHIP LINKING
    ///////////////////////////////////////////////////////////////////////////////
    $focus->save(FALSE);
    ////	END EMAIL SAVE/SEND SETUP
    ///////////////////////////////////////////////////////////////////////////////
    
    
    
    ///////////////////////////////////////////////////////////////////////////////
    ////	RELATIONSHIP LINKING
    $focus->load_relationship('users');
    $focus->users->add($current_user->id);
    Steve

  3. #3
    rogersugarsugar is offline Sugar Community Member
    Join Date
    Jun 2007
    Posts
    38

    Default Re: Sometimes 2 of a message in Sent Mail list

    If that will correct it, I hope it makes it into an update.

    I have also noticed that this is happening with other records, too.

    I have no intentions, however, of doing my own code changes, and then losing them at the next update.

    (We are doing a 3 month evaluation of SugarCRM, and I'm accumulating an impressive list of concerns :-/ I'm convinced it's time to write my own, after all. Just a simple, consistent infrastructure where everything just works!y)

  4. #4
    monsta is offline Sugar Community Member
    Join Date
    Jun 2006
    Location
    Brighton, Sussex - UK
    Posts
    19

    Default Re: Sometimes 2 of a message in Sent Mail list

    Further to this, if you save an email to draft and then send, you get four copies in the emails_contacts table!

    What versions are you guys running? We're on Version 4.5.1d (Build 1273)

    I haven't had time to test the 4.5.1e release yet, does anyone know if this has been fixed in that release?

  5. #5
    rogersugarsugar is offline Sugar Community Member
    Join Date
    Jun 2007
    Posts
    38

    Default Re: Sometimes 2 of a message in Sent Mail list

    Quote Originally Posted by monsta
    Further to this, if you save an email to draft and then send, you get four copies in the emails_contacts table!

    What versions are you guys running? We're on Version 4.5.1d (Build 1273)

    I haven't had time to test the 4.5.1e release yet, does anyone know if this has been fixed in that release?
    4.5.1e is what I'm using, and where I'm experiencing the problem...

  6. #6
    skeeby is offline Sugar Community Member
    Join Date
    Aug 2007
    Posts
    56

    Default Re: Sometimes 2 of a message in Sent Mail list

    Double entries only happen when i send an email to a recipient with cc to some other recipient

    gg

  7. #7
    swilliams is offline Sugar Community Member
    Join Date
    Apr 2007
    Posts
    21

    Default Re: Sometimes 2 of a message in Sent Mail list

    Found another case where duplicates can occur.

    Select a parent type, in my case Contacts and then a contact from the popup.

    Save as Draft.

    Edit and Save as Draft again, or send it, it will cause duplicate entries.

    It's caused by not having an "alternate_key" entry in (my case) emails_contactsMetaData.php in the indices array. Without that entry, it will not perform a check for duplicates before creating the relationship between emails and contacts.

    I added the following to my meta data file:

    array( 'name' => 'idx_emails_contacts',
    'type' => 'alternate_key',
    'fields' => array('email_id','contact_id')
    ),

    Don't forget to go to Admin->Repair->Rebuild Relationships to make any changes take effect.

    It should be an issue for any parent that doesn't have the proper entry in their metadata file:
    Example: emails_prospectsMetaData.php,emails_opportunitiesM etaData.php, etc...

    Steve

  8. #8
    simple is offline Sugar Community Member
    Join Date
    Jul 2005
    Posts
    259

    Default Re: Sometimes 2 of a message in Sent Mail list

    Hello

    We noticed the same problem (4.5.1e). I changed the file modules/Emails/Email.php.

    In the function create_list_query()

    Code:
           if($show_deleted == 0){
                            $where_auto = " emails.deleted=0 ";
                    }else if($show_deleted == 1){
                            $where_auto = " emails.deleted=1 ";
                    }
    changed to:

    Code:
            if($show_deleted == 0){
                            $where_auto = " emails.deleted=0 and ec.deleted=0";
                    }else if($show_deleted == 1){
                            $where_auto = " emails.deleted=1 ";
                    }
    It worked here.
    Last edited by simple; 2007-10-11 at 12:44 PM. Reason: better solution
    Cheers Pascal
    Simplicity GmbH

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. HOW-TO guide for Email Campaigns.
    By agupta in forum Marketing/Campaign Management
    Replies: 146
    Last Post: 2012-01-31, 03:08 PM
  2. Replies: 4
    Last Post: 2009-10-28, 10:21 AM
  3. error message list view setting
    By eigenwijs in forum Installation and Upgrade Help
    Replies: 0
    Last Post: 2007-02-16, 07:45 PM
  4. E-mail message causing an error when checking mail
    By toyd in forum General Discussion
    Replies: 1
    Last Post: 2007-01-23, 09:02 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
  •