Questions and discussion about using ProcessMaker: user interface, running cases & functionality
#816578
Dear all,

I am not sure if this happened to anyone else but when uploading input documents through the Multiple File Upload in the PM 3.2.1 Community Edition, tags are not commited tothe database. I made sure the Multiple File Upload field is correctly associated with the Input Document, but it has not helped.

For the file control (single file upload), it works fine.

I will try to fix it in a trigger, but if anyone has a different suggestion, please let me know.
#816796
I made the trigger to fix my bug. It may help you also in case you would like to change the tags for an input document after cases were already registered for a given process before. It will update the APP_DOCUMENT table based on tags defined in the INPUT_DOCUMENT table.

In case you have a variable in your tags, it will loop through the variables stored in the APP_DATA table and will try to find the value.
Code: Select all

//Fix the bug that prevents tags for input documents being committed to the database
$caseId = @@APPLICATION;
$query = "SELECT APP_DATA FROM APPLICATION WHERE APP_UID = '$caseId'"; 
$serializedVars = executeQuery($query); //get all the case variables allready committed to the database
$unserializedVars = unserialize($serializedVars[1]['APP_DATA']); //unserialize variables

//get the array of tags related to the input document from the INPUT_DOCUMENT_TABLE
$result = executeQuery("SELECT DOC_UID,INP_DOC_TAGS FROM INPUT_DOCUMENT INNER JOIN APP_DOCUMENT ON INPUT_DOCUMENT.INP_DOC_UID = APP_DOCUMENT.DOC_UID WHERE APP_DOCUMENT.APP_UID='$caseId'");

if (is_array($result) and count($result) > 0) {
foreach ($result as $row) { //loop through all the results returned
	$tagsToInsert = ""; //clear the string after loop
	$inpDocId = $row['DOC_UID']; //here we get the input document ID
	$tagsArray = explode(",",$row['INP_DOC_TAGS']); //convert the tags delimited by comma into an array
    
	if (is_array($tagsArray) and count($tagsArray) > 0) {
foreach($tagsArray as $tag){
	
   if (substr($tag,0,2) === "@@" || substr($tag,0,2) =="@#" ) { //testing if the tag start by @# or @@ to see if there is a variable
        $varToFind =substr($tag,2); //remove the first two characters if the tag is a variable
        $varValue = $unserializedVars[$varToFind]; //lookup the value of the variable in the unserialized string
	    $tagsToInsert .= $varValue . ","; //do not forget to add comma separator between tags
       
   } else {     //if the tag is not a variable, take just the string
      $tagsToInsert .= $tag . ",";
   }}}
	
$tagsToInsert = rtrim($tagsToInsert,","); //remove the last comma from the generated string

//update all records in the APP_DOCUMENT table
//in case you want to update tags for all input documents uploaded in all cases, remove AND APP_UID='$caseId' at the and of the query
$query = "UPDATE APP_DOCUMENT SET APP_DOC_TAGS='$tagsToInsert' WHERE DOC_UID='$inpDocId' AND APP_UID='$caseId'";
$result = executeQuery($query); 
}}
die(var_dump($result));
Hope this helps someone with the same problem.

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[…]

Betvisa clone scripts are pre-built software solut[…]