amosbatto wrote: ↑Tue Apr 30, 2019 10:13 pm
devbhanu wrote:I am facing similar issue. In first form the user1/requester upload the files and next task is assigned via actions by email to another user2 where he has to upload files and the next task is to trigger email with attachments. Here I can able to see the attachments from the user1 but not from the user2(actions by email) through email. Able to see the whole documents uploaded by the users(both) in the Documents where I have permissions to download but not able to view files uploaded by user2 as Email attachment.
Appreciate your Help ! Thank you
You can use the following trigger to attach all the uploaded file in a case to an email in PM 3.1.0 and later:
Code: Select all$caseId = @@APPLICATION;
$sql = "SELECT * FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND APP_DOC_STATUS='ACTIVE' ";
$aFiles = executeQuery($sql);
if (!is_array($aFiles)) {
throw new Exception("Error executing query: $sql");
}
$aAttach = array();
$g = new G();
foreach ($aFiles as $aFile) {
$aAttach[ $aFile['APP_DOC_FILENAME'] ] = PATH_DOCUMENT . $g->getPathFromUID($caseId) . PATH_SEP .
$aFile['APP_DOC_UID'] . '_' . $aFile['DOC_VERSION'] . '.' . pathinfo($aFile['APP_DOC_FILENAME'], PATHINFO_EXTENSION);
}
}
$aUser = userInfo(@@USER_LOGGED); //get email of logged user
PMFSendMessage(@@APPLICATION, 'manager@acme.com', $aUser['mail'], '', '',
'Client documents', 'clientTemplate.html', array(), $aAttach);
See:
https://wiki.processmaker.com/3.2/Proce ... sage.28.29
You can change the SQL query to search for files which were uploaded to a specific field by adding: AND APP_DOC_FIELDNAME='myField'
See the fields in the APP_DOCUMENT table: https://wiki.processmaker.com/3.2/File_ ... le_Storage
If the user can't see the file under Home > Documents, then you need to assign Process Permissions so that the user can access the Task and DynaForm where the file was uploaded.
Thank you Amos for the reply.
I did use the similar trigger to display files as a Email attachment.
In my process the requester1 uploads some files and submits the form, A another form is send to a requester2 through (link to fill the form which is accessed by actions by email) where he uploads some more files and submits the form. The Final manager have receive the files as a Email attachment from both requester1 and requester2.
My Issue is the files uploaded by the requester2(using actionsbyemail to fill a form) is not displayed as Email attachment when he submits the form to Manager as the manager can see the attachments from requester1 and also information from both the requester's in PDF format but not the files uploaded as email attachments provided by the requester2 . And as a manager(supervisor) he can able to see in Documents in processmaker all the uploaded files from both requesters. But not as a email attachment of requester2 files.
Code: Select all$aAttachFiles = array();
$caseId = @@APPLICATION;
$inDocUID = 'XXXXXX'; // Input document UID
$inDocQuery = "SELECT C.CON_VALUE AS FILENAME, AD.DOC_VERSION, AD.APP_DOC_UID, AD.DOC_UID
FROM APP_DOCUMENT AD
JOIN CONTENT C
ON AD.APP_DOC_UID = C.CON_ID
WHERE AD.APP_UID = '".$caseId."' AND C.CON_CATEGORY = 'APP_DOC_FILENAME' AND AD.APP_DOC_TYPE = 'INPUT' AND AD.DOC_UID = '".$inDocUID."'";
$inDoc = executeQuery($inDocQuery);
$g = new G();
if (is_array($inDoc)) {
foreach ($inDoc as $doc) {
$aAttachFiles[$doc['FILENAME']] = PATH_DOCUMENT . $g->getPathFromUID($caseId) . PATH_SEP .
$doc['APP_DOC_UID'] . '_' . $doc['DOC_VERSION'] . '.' . pathinfo($doc['FILENAME'], PATHINFO_EXTENSION);
}
}
PMFSendMessage($app, 'processmaker.test.com', ,'manager.com ', $subject, 'test.html', array(), $aAttachFiles);
I assigned all files to same input document. I have output document also attached in the same trigger too which i didn't copied here. Thanks.
Thank you so much for your help.