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
No Data