Questions and discussion about using ProcessMaker: user interface, running cases & functionality
#813995
Hi!.
I have a web entry with a dynaform that allows to upload a file. I also have a task to print the contents of the file variable.
The problem, it seems that the file variable is empty if i call it from a trigger, but if i use the form with "start new case" then i can get it.
Also, when i use a web entry, i can use the variable in another dynaform and it shows me the download link, but it doesn't have anything in the variable (seen in the debugger).
What can i do :(
Last edited by allanrp1 on Thu Apr 12, 2018 7:02 pm, edited 1 time in total.
User avatar
By amosbatto
#813996
What version of ProcessMaker are you using? In PM 3.2.1 and earlier, only File fields work in Web Entry, but MultipleFile (also known as "FileUpload") fields do not work.

In 3.2.2 and later, MultipleFile fields should work in Web Entry, but I haven't checked it, since the community edition hasn't yet been released.
By allanrp1
#813997
amosbatto wrote:What version of ProcessMaker are you using? In PM 3.2.1 and earlier, only File fields work in Web Entry, but MultipleFile (also known as "FileUpload") fields do not work.

In 3.2.2 and later, MultipleFile fields should work in Web Entry, but I haven't checked it, since the community edition hasn't yet been released.
I use 3.2 and i'm using single file uploader.
By allanrp1
#814002
Well it's very simple.
I just have one dynaform with a file upload input and a task.
I put the dynaform in a web entry and print the variable in a trigger in the task.
Just for testing i also put the dynaform in the task and set it the same variable.
it's simple, if you upload the file in the web entry, the trigger doesn't print anything, but if you load the file in the task, it prints the id of the document.
User avatar
By amosbatto
#814005
Allanrp1,
I see the problem. The coding for File fields in web entry forms wasn't updated, so it still has all the old bugs. When the web entry form is submitted, ProcessMaker does not create the @@contractFile variable with the ID of the uploaded file in a JSON array, like it normally would when normally submitting a Dynaform inside ProcessMaker. It only creates a @@contractFile_label variable which holds the filename of the uploaded file, but it isn't enclosed in quotation marks so it is bad JSON encoding.

To get around these problems, use this trigger code:
Code: Select all
if (!empty(@@contractFile_label) and @@contractFile_label != '[]') {
   $caseId = @@APPLICATION;
   $sql = "SELECT AD.*, C.CON_VALUE AS FILENAME 
      FROM APP_DOCUMENT AD, CONTENT C 
      WHERE AD.APP_UID='$caseId' AND AD.APP_DOC_FIELDNAME='contractFile'
      AND AD.APP_DOC_STATUS='ACTIVE' AND AD.APP_DOC_UID=C.CON_ID AND
      C.CON_CATEGORY='APP_DOC_FILENAME' ORDER BY AD.APP_DOC_INDEX DESC";
   $aFiles = executeQuery($sql);
    
   if (count($aFiles) == 0) {
      throw new Exception("File not found for case '$caseId' in APP_DOCUMENT table.");
   }    
   @@filename = $aFiles[1]['FILENAME'];
   @@fileUrl = "http://{$_SERVER['SERVER_ADDR']}:{$_SERVER['SERVER_PORT']}/sys" . @@SYS_SYS .
      "/en/neoclassic/cases/cases_ShowDocument?a=".$aFiles[1]['APP_DOC_UID'].
      "&v=".$aFiles[1]['DOC_VERSION'];
    
   //other information about the uploaded file:
   $aUser = userInfo($aFiles[1]['USR_UID']);
   @@fileUploader = $aUser['firstname'].' '.$aUser['lastname'].' ('.$aUser['username'].')';
   @@dateUploaded = $aFiles[1]['APP_DOC_CREATE_DATE'];
    
   //path where file is stored on server
   $g = new G();
   @@filePath = PATH_DOCUMENT. $g->getPathFromUID($aFile["APP_UID"]) .PATH_SEP. 
       $aFiles[1]['APP_DOC_UID'] .'_'. $aFile['DOC_VERSION'] .'.'. 
       pathinfo(@@filename, PATHINFO_EXTENSION);
} 
See the attached process for an example:
(37.41 KiB) Downloaded 236 times
By allanrp1
#814038
Thanks.
I wanted to get the url of the uploaded file, I did it in this way:
Code: Select all
$result = executeQuery("SELECT * FROM APP_DOCUMENT WHERE APP_UID='".@@APPLICATION."'");
if (is_array($result) and count($result) > 0) {
    @@resultado = $result[1]["APP_DOC_UID"];
	$fileId = @@resultado;
	$d = new AppDocument();
    $aFile = $d->Load($fileId); //get most recent version of file
    $aUser = userInfo($aFile['USR_UID']);
	$url = "myurl.com";
    @@fileUrl  = "http://".$url."/sys".@@SYS_SYS."/es/neoclassic/cases/cases_ShowDocument?a=$fileId&v={$aFile['DOC_VERSION']}";
}
And the APP_DOCUMENT has a variable name column so i can access to every doc that i want.
But, thanks!
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

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