Unofficial documentation how to do interesting things and work around problems in ProcessMaker

Moderator: amosbatto

Forum rules: Unofficial documentation for features which have not been tested by Quality Assurance or may change in future versions of ProcessMaker
By GimliMaker
#814716
Hi there, I've generate an outputdocument that is uploaded by the actors. Then I want to send an email to other person with that outputdocument attached;


The template is like this (rich text):

"Hi @#reqUserName,


Bla bla blal

@=USER_LOGGED

@=planDeEstDoc"

the trigger:

"$aUser = userInfo(@@USER_LOGGED);
$to = $aUser['mail'];
PMFSendMessage(@@APPLICATION, '[email protected]', $to, $to, '', 'Subject', 'template.html','', @=planDeEstDoc);
"

Neither variables are sent, on @=USER_LOGGED I only get an binary code, and the @= planDeEstDoc return an ID that isn't from the document output.


If someone could give me some help I would appreciate, cheers
#814718
@=USER_LOGGED is the ID of the logged in user, so you are getting the correct information. If you want the name of the user, then you need to use the userInfo() function to get that information about the user and pass it in the variables array to the PMFSendMessage() function.

How did you create your @=planDeEstDoc variable? Is it the ID of the Output Document definition?
If you want to attach an Output Document as an attachment to an email, see the programming example for attaching an Output Document file:
http://wiki.processmaker.com/3.1/Proces ... sage.28.29

Your trigger code will be something like this:
Code: Select all
//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 AD.DOC_VERSION = (
   SELECT MAX(DOC_VERSION) FROM APP_DOCUMENT WHERE APP_UID='$caseUID' AND
   DOC_UID='$outDocDef' AND APP_DOC_STATUS='ACTIVE')
   AND AD.APP_DOC_UID = C.CON_ID AND C.CON_CATEGORY = 'APP_DOC_FILENAME'";

$outDoc = executeQuery($outDocQuery);

if (is_array($outDoc) and count(outDoc) > 0) {
   $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 line if not generating a PDF file
   $aAttachFiles[$filename . '.doc'] = $path . '.doc'; //remove line if not generating a DOC file
}

$usr = userInfo(@@USER_LOGGED);
$userFullName = $usr['firstname'] .' '. $usr['lastname'];
$aVars = array(
   'userFullName' => $userFullName
);
@@resp=PMFSendMessage(@@APPLICATION, "[email protected]", $usr['mail'], "", "",
   "Case Report", "template.html", $aVars, $aAttachFiles);
Then put @#userFullName in your template instead of @=USER_LOGGED.

<?php if ($divisor == 0) { trigger_error(&q[…]

nike kd ELEVEN arizona pe. annually, nike hockey i[…]

entering august, the soccer on this planet cup con[…]

like a nature lover, i used to be delighted after […]