Questions and discussion about using ProcessMaker: user interface, running cases & functionality

Moderator: ArturoRobles

#829176
Hello,

I am using Processmaker 3.2 community version.

We are using a trigger script to generate and email the output document as an attachment. Mostly it works but for some random cases there is no attachment to the email. In the APP_DOCUMENT table, I can see an entry for the output document but the APP_DOC_STATUS is "Deleted". The document does exist as when I hack the script to use a hardcoded document Id (excluding status= ACTIVE condition), it gets attached successfully. 

I am using PMFGenerateOutputDocument to  generate the document. We are not doing any deletes as part of the script so I am clueless why the output document gets marked as deleted. If I reassign and try approval again, it does the same thing. So we end up with multiple output documents with status as deleted. Again, this happens just for a select few cases only.

See below script :

$aAttachFiles = array();
$aAttached = array();

$caseId = @@APPLICATION;

$from = "";
$to = array(
@@userEmail,
""
);
$bcc = "";
$subject=array(
"Test - Case #".@@CaseNumber." - ".@@=supplier." -".@@=testExplanation,
"Test2- Case #".@@CaseNumber." - ".@@=supplier
);


$outDocDef = "8228236345b4e8c4160abd5075536854";
$emailTemplate="emailEvent_1502067932539.html";

PMFGenerateOutputDocument($outDocDef);


$temp = G::getPathFromUID($caseId);

/*to attach uploaded documents to the email*/

$query = "SELECT AD.APP_DOC_UID, AD.DOC_VERSION, AD.APP_DOC_FILENAME AS FILENAME
FROM APP_DOCUMENT AD
WHERE AD.APP_UID='$caseId' AND AD.DOC_UID='-1' AND
AD.APP_DOC_STATUS='ACTIVE'
UNION
SELECT AD.APP_DOC_UID, AD.DOC_VERSION, C.CON_VALUE AS FILENAME
FROM APP_DOCUMENT AD, CONTENT C
WHERE AD.APP_UID='$caseId' AND AD.DOC_UID='$outDocDef' AND
AD.APP_DOC_STATUS='ACTIVE' AND AD.DOC_VERSION = (
SELECT MAX(DOC_VERSION) FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND
DOC_UID='$outDocDef' AND APP_DOC_STATUS='ACTIVE')
AND AD.APP_DOC_UID = C.CON_ID AND C.CON_CATEGORY = 'APP_DOC_FILENAME'";

$aFiles = executeQuery($query);

if (is_array($aFiles) and count($aFiles) > 0) {
foreach ($aFiles as $aFile) {
$d = new AppDocument();
$aDoc = $d->Load($aFile['APP_DOC_UID'], $aFile['DOC_VERSION']);
$filename = $aDoc['APP_DOC_FILENAME'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$g = new G();

if(empty($ext)){
$ext='pdf';
$filePath = PATH_DOCUMENT . $temp . PATH_SEP . 'outdocs'. PATH_SEP . $aFile['APP_DOC_UID'] .'_'. $aFile['DOC_VERSION'] .'.'. $ext;
$fileName = $filename .'.'. $ext;
$aAttached[$fileName] = $filePath;
}else{
$filePath = PATH_DOCUMENT . $temp . PATH_SEP .$aFile['APP_DOC_UID'] .'_'. $aFile['DOC_VERSION'] .'.'. $ext;
$fileName = $filename;
}

$aAttached[1] = PMFAddAttachmentToArray($aAttached[1], $fileName, $filePath);
}

PMFSendMessage($caseId, $from, $to[1], '', '',$subject[1], $emailTemplate, array(), $aAttached[1]);


}


PMFSendMessage(@@APPLICATION, $from, $to[0], $cc, '', $subject[0], $emailTemplate, array(''), $aAttached, TRUE, 0, "");

Appreciate for your help.

Thanks
Attachments
APP_DOCUMENT.png
APP_DOCUMENT.png (28.67 KiB) Viewed 1168 times

Hello again ;) I would like to test / implement a[…]

Processmaker Triggers

How can i console log data from triggers , i use[…]

hi I encountered a problem while using the API I u[…]

Hello, I have 8 input documents in one of my proc[…]