Empty Cases created by Email Arciving User (SNIP)

Hello friends...

Cloud - Enterprise - v11.1  (>11.2 at end of month)

I recently enabled the Email Archiving in production after being impressed with it in sandbox.   I am mainly using it to BCC the archiving email for certain Automated Process Definition (process email templates) related to our cases, rma's...  It means our support folk now have visiblitly of the rma when email automatically, and things like the email notifications to customers when we recieve or ship things.  It's really cool for that especially with the new Interactions dashlet.

However, in production I am now getting a number of empty cases being created :-(

They are created by the email archiving user:

And in audit log, SNIP:

They do not even have an email related to them:

and looking at emails in the Email module the times don't match the created time of the case?

I know I can delete them (I have a dashlet on my admin dash for this)...  

  • Does anyone know what I can investigate next???

Thank you....

Parents
  • I have not used SNIP but if you look at: 

    modules/SNIP/SugarSNIP.php

    public function importEmail concludes with a call to relateRecords:

            // Relate records
    
            if(!empty($e->subject)) {
    
                $this->relateRecords($e);
    
            }

    And the first thing that does is create a case.

        /**
         * Relate records to this email
         * @param Email $e
         */
        protected function relateRecords($e)
        {
            // relate a case
            $case = BeanFactory::newBean('Cases');
            $subj = str_replace("%1", '(\d+)', preg_quote($case->getEmailSubjectMacro(), "#"));
            if(preg_match("#$subj#", $e->subject, $match) && !empty($match[1])) {
                $caseid = $match[1];
                $GLOBALS['log']->info("Trying to link to case $caseid");
                $case->retrieve_by_string_fields(array("case_number" => $caseid));
                if(!empty($case->id)) {
                    $case->load_relationship("emails");
                    $case->emails->add($e);
                }
            }
            // allow custom stuff
            $e->call_custom_logic("after_email_import");
        }
    

    (Curious that it still uses retrieve_by_string_fields which was deprecated a long time ago.)

    So here is my thought... 

    is it possible that the first line: 

    $case = BeanFactory::newBean('Cases');

    Is actually saving the empty case bean, but then failing to pass the if statement for the macro and therefore not linking the email to the case?

    I guess I've never used BeanFactory::newBean without fist making sure I actually wanted to create and save a bean...

    Or perhaps there is something in your after_email_import custom logic?

    I'll be curious to see what you find.
    Francesca

Reply
  • I have not used SNIP but if you look at: 

    modules/SNIP/SugarSNIP.php

    public function importEmail concludes with a call to relateRecords:

            // Relate records
    
            if(!empty($e->subject)) {
    
                $this->relateRecords($e);
    
            }

    And the first thing that does is create a case.

        /**
         * Relate records to this email
         * @param Email $e
         */
        protected function relateRecords($e)
        {
            // relate a case
            $case = BeanFactory::newBean('Cases');
            $subj = str_replace("%1", '(\d+)', preg_quote($case->getEmailSubjectMacro(), "#"));
            if(preg_match("#$subj#", $e->subject, $match) && !empty($match[1])) {
                $caseid = $match[1];
                $GLOBALS['log']->info("Trying to link to case $caseid");
                $case->retrieve_by_string_fields(array("case_number" => $caseid));
                if(!empty($case->id)) {
                    $case->load_relationship("emails");
                    $case->emails->add($e);
                }
            }
            // allow custom stuff
            $e->call_custom_logic("after_email_import");
        }
    

    (Curious that it still uses retrieve_by_string_fields which was deprecated a long time ago.)

    So here is my thought... 

    is it possible that the first line: 

    $case = BeanFactory::newBean('Cases');

    Is actually saving the empty case bean, but then failing to pass the if statement for the macro and therefore not linking the email to the case?

    I guess I've never used BeanFactory::newBean without fist making sure I actually wanted to create and save a bean...

    Or perhaps there is something in your after_email_import custom logic?

    I'll be curious to see what you find.
    Francesca

Children
  • Hi all, hello ...

    This was a bit beyond my skill level and to be honest I have just been deleting the blank cases created throughout the day, as and when I think about it.

    Yesterday I finally rasied a case for it and have learned it is already a reported defect!   So that is good to know.

    Here is the link for anyone getting the same issue (we are now in Sugar Sell Advance v12 and it's the same):

    https://portal.sugarondemand.com/#supp_Bugs/88706

    ...and to save you a click:


    88706  
    Description  

    When an email is archived using the SNIP email archiving address and the case macro, a blank Case will be added to the Cases module.  

    Steps to duplicate (v11.1 or v11.2):

    1. Enable SNIP email archiving.

    2. Create a case (or use existing).

    3. Send an email to the SNIP address with a case macro matching the case number from step #2.  

    Expected Results: Email is archived, existing case is linked to archived email.  

    Actual Results: Email is archived, existing case is linked to archived email, new blank case is created.  

    Issue not replicable in 11.0.2 but is present in 11.1 and 11.2.


    *Edit* to add that I have now setup data Archiver to delete these phantom cases for me while I await the official fix.

    This will mean the scheduler (Run Active Data Archives/Deletions) will do the deletion for me weekly:  On thehour; 22:00; Saturday, or whenever I choose to run manually it from 'perform now'.

    This is what I setup in the Data Archiver if it helps too. It  tested perfectly.

    Again - i hope this info is useful for others with similar issues.
    Best regards all,
    Luke.