Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By mahdavisharif
#815240
hello
i have need to report from grid in a dynaform in the following process but when i download the CSV file from input document in task dynaform and rout the task, all data in other dynaforms are deleted . how can solve this problem?
Attachments
(371.47 KiB) Downloaded 253 times
User avatar
By amosbatto
#815252
In what task, what Dynaform and what Input Document in your process do you see this problem? Is it caused by a trigger? If so, which trigger?

If you have a die(), exit() or header("location: url") in one of your triggers after a DynaForm, then the variables from that Dynaform won't be saved to the database. You have to use PMFSendVariables(@@APPLICATION, array(...)) to save the Dynaform's variables before killing the trigger or redirecting the web browser. If you have a link in a DynaForm, make sure that it it is opening in a new tab/window, so it doesn't prevent the Dynaform from being saved.
#815278
thanks for your attention, i have some change on your trigger that you mention in (viewtopic.php?f=41&t=710430&p=790694#p790694) post and put it before second dynaform in paralell tasks such as human transport costs but my problem being after download the csv file generated. for example when i download the file generate after human transport cost and approve end process in next step and go to equipment costs task i see all field in this dynaform have been null.
this my trigger before second dynaform in parallel tasks:
Code: Select all
@@csvFilename = '';
@@csvLink = '';

if (isset(@=ptransport) and is_array(@=ptransport) and count(@=ptransport)) {
	$aCsv = array();
	//set the first row in the CSV file to the IDs of the grid fields
	$aColumnHeaders = array_keys(@=ptransport[1]);
	$line = '';
	foreach ($aColumnHeaders as $fieldId) {
		$line .= (empty($line) ? '' : ';') . $fieldId;
	}
	$aCsv[] = $line;
	
	//set each data row in CSV file:
	foreach (@=ptransport as $aRow) {
	   $line = '';
       foreach ($aColumnHeaders as $fieldId) {
		   $val = $aRow[$fieldId];
		   if (is_array($val) or is_object($val)) {
			  $val = json_encode($val);
		   }
		   //sanitize CSV data to handle double quotation marks, commas, semicolons, 
		   //spaces and new lines 
		   $val = str_replace('"', '""', $val);
           if (preg_match('/[,;"\n\r]/', $val) or trim($val) != $val) { 
              $val = '"' . $val . '"'; 
           }
		   $line .= (empty($line) ? '' : ';') . $val; 
	   }
	   $aCsv[] = $line;
	}
	
	//create a temporary output file:
	$path = tempnam(sys_get_temp_dir(), "transport_") . ".csv";
	file_put_contents($path, implode("\n", $aCsv));
					  
	$inpDocId = '1218872075b4ad7451ca8d9021570171'; //set to ID of the Input Document
	//upload temp CSV file to PM:
	@@fileId = PMFAddInputDocument($inpDocId, null, 1, 'INPUT', 'CSV file of products', 
		'add', @@APPLICATION, @%INDEX, @@TASK, @@USER_LOGGED, 'file', $path);
					  
	unlink($filename); //delete temporary CSV file
					  
	if (empty(@@fileId)) {				  
	   $g = new G();
	   $g->SendMessageText("Unable to upload CSV file to current case.", "ERROR");
	}
	else {				  
	   @@csvLink = (G::is_https() ? 'https://' : 'http://') .
		  $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].'/sys' . 
		  @@SYS_SYS.'/en/neoclassic/cases/cases_ShowDocument?a='.@@fileId;
	   @@csvFilename = pathinfo($path, PATHINFO_BASENAME);
	}
}
Attachments
(370.94 KiB) Downloaded 230 times
User avatar
By amosbatto
#815316
I see a 2 problems in the code.

Change the code from:
Code: Select all
        unlink($filename); //delete temporary CSV file
					  
	if (empty(@@fileId)) {				  
	   $g = new G();
	   $g->SendMessageText("Unable to upload CSV file to current case.", "ERROR");
	}
	else {				  
	   @@csvLink = (G::is_https() ? 'https://' : 'http://') .
		  $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].'/sys' . 
		  @@SYS_SYS.'/en/neoclassic/cases/cases_ShowDocument?a='.@@fileId;
	   @@csvFilename = pathinfo($path, PATHINFO_BASENAME);
	}
}
To:
Code: Select all
        unlink($filename); //delete temporary CSV file
        $g = new G();
					  
	if (empty(@@fileId)) {				  
	   $g->SendMessageText("Unable to upload CSV file to current case.", "ERROR");
	}
	else {				  
	   @@csvLink = ($g->is_https() ? 'https://' : 'http://') .
		  $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].'/sys' . 
		  @@SYS_SYS.'/en/neoclassic/cases/cases_ShowDocument?a='.@@fileId;
	   @@csvFilename = pathinfo($path, PATHINFO_BASENAME);
	}
}
After you make those changes and you run in the case with Debug Mode enabled, do you see an "__ERROR__" variable? Does the URL work which is held by the "csvLink" variable?
#815317
yes,the URL held by "csvLink" variable but, after run the case i see this error:

Non-static method G::getPathFromUID() should not be called statically, assuming $this from incompatible context

what can i do for solve this problem? and also all problems talk about them in previous posts not solved yet.
thanks for your help.

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