Page 1 of 1

Wrong Dropdown in Grid, Using array variable

Posted: Wed Mar 18, 2020 9:47 pm
by dongpeng121
My process has 3 tasks, Task2 DynaForm has a dropdown in a grid, and its options are from an array variable, which is set in a trigger using sql to select from a PM Table. In Task3, I copy the grid with dropdown from Task2, however, the value dispalyed of the two dropdowns in the grid are not what I set in Task2. In debug mode, the value of the dropdowns are the same with Task2.

Thank you.
My PM version is 3.4.7 community.

The trigger to select options from a PM Table.
Code: Select all
@%app_no = (int)@@APP_NUMBER;
$a = @%app_no;
$sql = "SELECT F_TITLE FROM PMT_TITLE WHERE F_APP_NUMBER = '$a'";
$ta = executeQuery($sql);
$out =array();
@@title_array = array();
for ($i = 1; $i <= count($ta); $i++) {
	$out[1] = $ta[$i]['F_TITLE'];
	@@title_array[$i] = $out;
}
The tigger to set the array variable.
Code: Select all
$t = '';
if (!empty(@=gridVar001)) {
	foreach (@=gridVar001 as $g){
   		$t  = $g['title_id_label'];
		@%app_no = (int)@@APP_NUMBER;
		$a = @%app_no;
		$insert = "INSERT INTO PMT_TITLE (ID, F_TITLE, F_APP_NUMBER) VALUES (NULL,'$t', '$a')";
		executeQuery($insert);
	}
}

Re: Wrong Dropdown in Grid, Using array variable

Posted: Mon Apr 06, 2020 1:08 am
by chieunh
In ProcessMaker, grid starting from 1.
To copy grid 1 to grid 2, you can try:
Code: Select all
//clear value grid2
@=grid2 = [];
$grid2Index = 1;
//copy grid 1 to grid 2
foreach (@=grid1 as $key => $value) {
	@=grid2[$grid2Index] = ["grid_drop" => $value];
	$grid2Index++;
}