Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#815599
Hi folks,

I have process which allows the user to upload a spreadsheet using a File control which then, at a later task, populates a grid. This works fine when the process is initiated from New Cases.

However, if I initiate this from a Web Entry the file appears to upload correctly (it appears on the Dynaform and if you click on the link it downloads correctly) but the grid is empty and an error is generated in debug Error loading Document /0. This row doesn't exist! which makes sense because there is nothing in the Input Documents.

I'm using the same code in both instances - is there something special I have to do for the web entry?

I have attached the process and the spreadsheet.

I am using Community 3.2.1

thanks as always
Greg
Attachments
(271.64 KiB) Downloaded 385 times
Spreadsheet used to populate grid
(38.31 KiB) Downloaded 267 times
#815622
The problem is that Web Entry is not setting the @@printSerialsRecord variable, so you are going to have to lookup the ID of the file in the APP_DOCUMENT table. Change this:
Code: Select all
$fileId = json_decode(@@printSerialsRecord)[0];
To:
Code: Select all
if (!empty(@@printSerialsRecord)) {
   $fileId = json_decode(@@printSerialsRecord)[0];
}
else {
   $sql = "SELECT * FROM APP_DOCUMENT WHERE APP_UID='".@@APPLICATION."' AND APP_DOC_STATUS='ACTIVE' 
      AND APP_DOC_FIELDNAME='printSerialsRecord'";
   $result = executeQuery($sql);
   if (empty($result)) {
       throw new Exception("No uploaded file for this case.");
   }
   $fileId = $result[1]['APP_DOC_UID']; 
}
#815641
Hi Amos,

I tried that code but I now debug gives me the error"

Could not open /opt/processmaker/shared/sites/workflow/files/988/729/474/5b70c10c27d2b5028035781/2530427255b70c10d197097058515343_1. for reading! File does not exist.

There is still no document in Information/Uploaded documents. However when I run the SQL query you included in the code above I do get an appropriate result with the correct file names in APP_DOC_FILENAME and APP_DOC_TITLE (see attached CSV).

Thanks for your time. I appreciate your help very much.

cheers
Greg
Attachments
(678 Bytes) Downloaded 239 times
#815666
Based on your database record, the correct path to the file should be:
/opt/processmaker/shared/sites/workflow/files/988/729/474/5b70c10c27d2b5028035781/2530427255b70c10d197097058515343_1.xlsx

It looks like the code is not able to get the correct file extension.
To verify that this is the problem, change the "Upload Print Serial Record" trigger from:
Code: Select all
   $ext = pathinfo($filename, PATHINFO_EXTENSION);
to:
Code: Select all
   $ext = pathinfo($filename, PATHINFO_EXTENSION); 
   @@ext = $ext;
And then check whether the "ext" variable is set to "xlsx" in the debugger when running a case.

Maybe pathinfo() can't handle your filename. Try uploading a file with a simpler filename (like "mysheet.xlsx") and see if you get the same problem.

Also, you should change from PhpExcel to PhpSpreadsheet. See: https://wiki.processmaker.com/3.1/Grid_ ... preadsheet

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]