Check if all items are marked in a variable check list

From pmusers
Jump to: navigation, search

This example shows how to create a variable list of check items, which can change with each case and check whether each of these items has been marked as completed.

Process: Variable_check_list-1.pmx (right click and select Save link as)
Author: Amos Batto (
Version: 1.0 (2018-06-14)
Tested in: ProcessMaker 3.2.1 Community in Debian 8.4 with PHP 5.6.20 and Firefox 51

Create a process with an exclusive gateway which will loop back to a previous task if all the items in a check list are not completed:


Then, create a Dynaform with a grid associated with a variable named "itemsToCheckGrid". This grid has a text box with the ID "item" where the user will enter an item to be checked. The user can enter a variable number of items.


Then, in a subsequent Dynaform, create a checkgroup whose variable is "itemsToCheckGroup". In its properties, set its datasource to be "array variable" and its data variable to be: @@itemsToCheckArray


Then, create the following trigger to place each of the items from the grid in an array variable named "itemsToCheckArray" which will populate the list of options in the checkgroup:

@=itemsToCheckArray = array();

if (!empty(@=itemsToCheckGrid)) {
   foreach (@=itemsToCheckGrid as $aItem) {
        @=itemsToCheckArray[] = array ($aItem['item'], $aItem['item']);

Set this trigger to fire before the above DynaForm with the checkgroup.

Finally, right click on the exclusive gateway and set the conditions to either continue onto Task 3 if all the items are check list are completed or loop back to Task 2, if some of the items are not marked as completed.


The condition to loop back to Task 2 checks whether some of the items in the checkgroup were not marked. In this situation, the number of rows in the grid will be greater than the number of marked items in the checkgroup:

!isset(@=itemsToCheckGrid) or !isset(@=itemsToCheckGroup) or count(@=itemsToCheckGrid) > count(@=itemsToCheckGroup)

The condition to continue to Task 3 counts the number of rows in the grid and verifies that the checkgroup has the same number of marked items in the checkgroup:

isset(@=itemsToCheckGrid) and isset(@=itemsToCheckGroup) and count(@=itemsToCheckGrid) == count(@=itemsToCheckGroup)

Note: The isset() function is used to ensure that both the grid and checkgroup variables were defined. If the user accessed the Steps menu to skip the two Dynaforms containing the grid and checkgroup or did not submit these two Dynaforms, then these variables might not have been defined.

When a case is run in this process, the user assigned to Task 1 will first enter the items to be completed in the grid:


Then, the user assigned to Task 2 will mark the items in the checkgroup which have been completed:


In this example, the subsequent gateway will route the case back to Task 2, because the user hasn't marked all the items in the checklist.

Note: If needing to check whether the first item is marked, then use this condition:

count(@=itemsToCheckGrid) >= 1 and in_array(@=itemsToCheckGrid[1]['item'], @=itemsToCheckGroup)

To check whether the second item is marked, then use this condition:

count(@=itemsToCheckGrid) >= 2 and in_array(@=itemsToCheckGrid[2]['item'], @=itemsToCheckGroup)