Question

Within the BPM application ProcessMaker, I am trying to copy rows out of one grid within a dynaform to a subsequent grid within a second dynaform. I only want to copy over the rows from the first grid where the checkboxes are checked on. The user does not need to see the unchecked rows.

I tried to have a trigger run BEFORE the subsequent grid and loop through the first grid and check where rows have checkboxes turned On but it doesn't seem to copy anything. Below is the code for the trigger. What am I doing wrong?

 @=new_grid = array();
 $tot = count(@=original_grid);
   for ($i = 1; $i <= $tot; $i++) {
    if ((@=original_grid[$i]['my_checkbox']) == 'On') {
    @=new_grid[$i] = array(
  'field1'    = @=original_grid[$i]['field1'],
  'field2'    = @=original_grid[$i]['field2'],
  'field3' = @=original_grid[$i]['field3'],
  'field4' = @=original_grid[$i]['field4'],
  'field5' = @=original_grid[$i]['field5'],
  'field6' = @=original_grid[$i]['field6']
  );
}
}
Was it helpful?

Solution 2

this one took a while to figure out. turns out, i had my trigger placed in the wrong location. I needed to place the trigger AFTER derivation/routing. And here is the revised code i ended up using:

$newGrid = max(array_keys(@=newGrid));
$i = 0;
foreach(@=newGrid as $r){
  if($r['my_checkbox'] == "On")
  {
     $i = $i + 1;
     @=newGrid[$newGrid + $i] = $r; 
  }
}

OTHER TIPS

Is the assignment of the variable to a field in an array you use = instead of =>. Like 'field1' => @=original_grid[$i]['field1'],

You could end the trigger with exit and add some echo's before that. Also in the process designer you can enable the debugger. In this way you can view variables, with there values, in when running a process. Also, you can view whether a trigger is fired and whether there were any errors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top