- Mon Sep 17, 2018 7:20 pm
#816104
Hi Amo,
I'm using PM 3.2.2, and I tried to generate an output document and then send as attachemnt in an email.
Any ideas on how to combine the following code into one trigger?
Example Emailing Generated Output Document Files:
Yuan
I'm using PM 3.2.2, and I tried to generate an output document and then send as attachemnt in an email.
Any ideas on how to combine the following code into one trigger?
Example Emailing Generated Output Document Files:
Code: Select all
Generate output document
//set to the Output Document definition's unique ID:
$outDocDef = "691319281570bc9938b4460028767596";
$caseUID = @@APPLICATION; //Unique ID for the current case
$aAttachFiles = array();
$outDocQuery = "SELECT AD.APP_DOC_UID, AD.DOC_VERSION, C.CON_VALUE AS FILENAME
FROM APP_DOCUMENT AD, CONTENT C
WHERE AD.APP_UID='$caseUID' AND AD.DOC_UID='$outDocDef' AND
AD.APP_DOC_STATUS='ACTIVE' AND AND AD.APP_DOC_UID = C.CON_ID AND
C.CON_CATEGORY = 'APP_DOC_FILENAME' AND AD.DOC_VERSION = C.CON_PARENT
ORDER BY AD.DOC_VERSION DESC";
$outDoc = executeQuery($outDocQuery);
if (!empty($outDoc)) {
$g = new G();
$path = PATH_DOCUMENT . $g->getPathFromUID($caseUID) . PATH_SEP . 'outdocs'. PATH_SEP .
$outDoc[1]['APP_DOC_UID'] . '_' . $outDoc[1]['DOC_VERSION'];
$filename = $outDoc[1]['FILENAME'];
$aAttachFiles[$filename . '.pdf'] = $path . '.pdf'; //remove if not generating a PDF file
$aAttachFiles[$filename . '.doc'] = $path . '.doc'; //remove if not generating a DOC file
}
$usr = userInfo(@@USER_LOGGED);
$from = "admin@processmaker.com"; //set to the email account set in Admin > Email Servers
@@resp=PMFSendMessage(@@APPLICATION, $from, $usr['mail'], "", "",
"Case Report", "caseReportTemplate.html", array(), $aAttachFiles);
Code: Select all
Many Thanks,//set to the Unique ID of the Output Document:
$outDocId = '84581368556d0b69010a355067195050';
$caseId = @@APPLICATION;
PMFGenerateOutputDocument($outDocId);
//retrieve info from the database about the generated output document file
$query = "SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND
DOC_UID='$outDocId' AND APP_DOC_STATUS='ACTIVE'";
$result = executeQuery($query);
if (!is_array($result) or count($result) == 0) {
die("Error: Unable to find generated Output Document in database.");
}
$d = new AppDocument();
$aFile = $d->Load( $result[1]['APP_DOC_UID'] );
//change from 'http://' to 'https://' if using SSL
//change 'pdf' to 'doc' for MS Word file
@@outDocUrl = 'http://' . $_SERVER['SERVER_NAME'] .
// ':' . $_SERVER['SERVER_PORT'] . //uncomment if needing a port number
'/sys'. @@SYS_SYS . '/en/neoclassic/cases/cases_ShowOutputDocument?a=' .
$aFile['APP_DOC_UID'] . '&v='. $aFile['DOC_VERSION'] . '&ext=pdf';
@@outDocFilename = $aFile['APP_DOC_FILENAME'] .'_'. $aFile['DOC_VERSION'] .'.pdf';
Yuan