Page 1 of 1

Inconsistent display of multiFile controls when viewed via actions by email

Posted: Mon Apr 29, 2019 4:37 am
by michaelg4s
Hi,

A colleague and I are trying to develop a process that uses actions by email. We've encounter an issue where files uploaded with a multiFile control are not always shown to the user...and I am not sure what determines whether or not files can be seen.

The multiFile control is embedded in a subform that is set to View.

Any guidance would be appreciated!

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Mon Apr 29, 2019 4:38 am
by michaelg4s
The recipient of the email needs to be able to download the files and view their contents.

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Mon Apr 29, 2019 9:32 pm
by amosbatto
If you are using PM 3.1.3 or later and the email recipient needs to be able to download the files, then either the email recipient will need to be logged into ProcessMaker and have Process Permissions to access the files or you need to add the following line to your env.ini file:
Code: Select all
disable_download_documents_session_validation = 1
See:
https://wiki.processmaker.com/3.2/Confi ... estriction

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Tue Apr 30, 2019 4:15 am
by avanzyl
Hi,

The issue is actually that the files aren't even displayed to the next user that receives an actions by email. And if this user uploads a file and is sent an email to complete another actions by email task he cannot even see the uploaded file that he uploaded. We are using the corporate version.

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Tue Apr 30, 2019 8:46 pm
by devbhanu
Hi,
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

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Tue Apr 30, 2019 10:13 pm
by amosbatto
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, '[email protected]', $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.

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Tue Apr 30, 2019 11:09 pm
by amosbatto
avanzyl wrote: Tue Apr 30, 2019 4:15 am The issue is actually that the files aren't even displayed to the next user that receives an actions by email. And if this user uploads a file and is sent an email to complete another actions by email task he cannot even see the uploaded file that he uploaded. We are using the corporate version.
If you are using the link to Dynaform option in your Actions By Email, then put the File/MultipleFile field in your Dynaform and the user will be able to access the previously uploaded file(s). Make sure that you give the user Process Permissions to access the file or edit your env.ini file to turn off permissions checking as I explained in the previous post.

If you are using one of the other two options in Actions by Email, then you can add a variable to your email template, like this:
@#fileLinks

Then, create a trigger which is fired before the email is sent out which will create links to the files and place them inside the @@fileLinks variable.

For example:
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");
}

@@fileLinks = "<ul>\n";
$g = new G();
$baseUrl = ($g->is_https() ? "https://" : "http://") .$_SERVER['HTTP_HOST'].'/sys'[email protected]@SYS_SYS.
    '/'[email protected]@SYS_LANG.'/'[email protected]@SYS_SKIN.'/cases/cases_ShowDocument?';

foreach ($aFiles as $aFile) {
   $fileUrl = $baseUrl . 'a=' . $aFile['APP_DOC_UID'] .  '&v='. $aFile['DOC_VERSION'];
   @@fileLinks .="<li> <a href=\"$fileUrl\">{$aFile['APP_DOC_FILENAME']}</a></li>\n";
}
@@fileLinks .= "</ul>";

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Thu May 02, 2019 1:19 pm
by devbhanu
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, '[email protected]', $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.

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Thu May 02, 2019 7:44 pm
by amosbatto
devbhanu wrote: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.
You need to examine your APP_DOCUMENT table and see how the second file is being stored in your database. (I recommend using PhpMyAdmin.) It probably isn't being saved as an Input Document in the database. Then, adjust your SQL query to be able to retrieve that second file.

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Mon May 06, 2019 5:45 am
by avanzyl
Hi,

Since the cloud servers have been recently updated, various bug fixes and improvements were implemented, I have not been able to reproduce my original issue.

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Tue May 07, 2019 5:39 pm
by devbhanu
amosbatto wrote: Thu May 02, 2019 7:44 pm
devbhanu wrote: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.
You need to examine your APP_DOCUMENT table and see how the second file is being stored in your database. (I recommend using PhpMyAdmin.) It probably isn't being saved as an Input Document in the database. Then, adjust your SQL query to be able to retrieve that second file.
Thanks Amos for the response.
Is there is other option to view the APP_Document table or resolve the issue as I don't have credentials for the PhpAdmin.
I have a question regarding the actionsbyEmail - here I am using link to fill a form option to submit the task and no need to login to processmaker. As we need assign Assignment rules for the task3 , I used (reports to) the case is assigned to approver of the task2 . If we fill the form and attach the documents through case , the attachments are showing in the email but not when the requester2 submits through email. What will be option for the assignment rules if we are using actionsbyEmail and is not the user of processmaker. I'm sorry if confusing you , in learning progress figuring out the issues through out the process. task1(requester1), task2(approver),task3(requester2)..mail to manager.

Thanks for your help!

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Tue May 07, 2019 8:23 pm
by amosbatto
devbhanu wrote: Tue May 07, 2019 5:39 pm Is there is other option to view the APP_Document table or resolve the issue as I don't have credentials for the PhpAdmin.
Install the same version of ProcessMaker on your local machine. Import your process. When importing, chose the option to keep the same UIDs.

Add this code to your trigger to save your query as a case variable:
@@query = $inDocQuery;

Then, run a case in Debug Mode and look at your query variable. Then, look at what is in your APP_DOCUMENT table in PhpMyAdmin. Try to execute your query in MySQL and see what is returned. These are the basic steps to solving any programming problem.

Re: Inconsistent display of multiFile controls when viewed via actions by email

Posted: Tue May 07, 2019 9:00 pm
by amosbatto
devbhanu wrote: Tue May 07, 2019 5:39 pm I have a question regarding the actionsbyEmail - here I am using link to fill a form option to submit the task and no need to login to processmaker. As we need assign Assignment rules for the task3 , I used (reports to) the case is assigned to approver of the task2 . If we fill the form and attach the documents through case , the attachments are showing in the email but not when the requester2 submits through email. What will be option for the assignment rules if we are using actionsbyEmail and is not the user of processmaker. I'm sorry if confusing you , in learning progress figuring out the issues through out the process. task1(requester1), task2(approver), task3(requester2)..mail to manager.
If you use PMFSendMessage() in a trigger to send the email to Requester2, then you can attach the files to the email, so the Requester2 can view the files in the email. It is question of getting your database query correct to find the files in the APP_DOCUMENT table in order to attach them.

You can use web entry if your Requester1 isn't a registered user in ProcessMaker. If your Requester2 isn't a registered user in ProcessMaker, then create a fake user inside ProcessMaker who will always be assigned to Task3 and use cyclical assignment. In your Actions by Email definition, unmark the option Force User Login.

If you want to send an email to the manager when Requester2 submits. Then you can create a trigger after routing in Task3 to send the email. If the manager is the Approver from Task2, then in Task 2 add this trigger:
@@managerId = @@USER_LOGGED;

Then, you can use this to get the manager's email in your trigger after routing in Task3:
$managerEmail = userInfo(@@managerId)['mail'];