0

We have been working on implementing some business processes using ProcessMaker. We have been observing an issue regarding attachments in sending email through ProcessMaker.

Here is the issue in detail.

  1. We have a timer task in which it sends some emails to business users with some attachment produced by PM. But we have been observing that emails are sent sometimes without attachment but sometimes email contains attachment.

  2. To dig down the problem we have checked each step before sending email but we have found that attachment file exists before sending email.

  3. In any process flow, email sending with attachment is working perfectly. But for timer task sometimes emails are sent without attachment and sometimes email is sent without attachment.

  4. Following is the code block which is executed on trigger of the timer task.

    @%emailCounter++;
    
    try{
    
        $to = 'xxxx@gmail.com';
    
        $caseId = @@APPLICATION;
    
        $aAttachments = [];
    
        @@debugStr = "";
    
        @@fileQuery = "select `APP_DOC_UID`, `DOC_VERSION` FROM `APP_DOCUMENT` where `APP_UID`='$caseId' order by `DOC_VERSION` desc limit 1";
        $aFiles = executeQuery(@@fileQuery);
    
        @@debugStr .= ";<br/> File counts = ".count($aFiles);
    
        foreach ($aFiles as $aFile)
        {
            @@debugStr .= ";<br/> File = ".$aFile['APP_DOC_UID'];
    
            $oDoc = new AppDocument();
            $aDocInfo = $oDoc->Load($aFile['APP_DOC_UID'], $aFile['DOC_VERSION']);
    
            @@debugStr .= ";<br/> File Info = ".json_encode($aDocInfo);
    
            $ext = '.pdf';  //set to '.doc' if sending a DOC file
            $g = new G();
            $pathToFile = PATH_DOCUMENT . $g->getPathFromUID(@@APPLICATION) . PATH_SEP . 'outdocs' .  PATH_SEP . $aFile['APP_DOC_UID'] . '_' . $aDocInfo['DOC_VERSION'] . $ext;
            @@debugStr .= ";<br/> File path = ".$pathToFile;
            $filename = @@selfNamePDF;
    
            $aAttachments = PMFAddAttachmentToArray($aAttachments, $filename, $pathToFile);
    
        }
    
        @@subjectLine = '[Test - attachment] '.@@title;
    
        PMFSendMessage(@@APPLICATION, 'yyyy@zzz.com', $to , 'pppp@gmail.com','' , @@subjectLine, 'TestEmail.html', array(), $aAttachments);
    
    } catch (Exception $e) {
        PMFSendMessage(@@APPLICATION, 'yyyy@zzz.com', $to , 'mmmm@gmail.com','' , 'Exception Occured - '.$e->getMessage(), 'TestEmail.html', array(), $aAttachments);
    }
    

Looking for a direction in which we can think to get rid of this problem.

0 Answers0