Please rate how useful you found this document: 
Average: 2.7 (6 votes)

Grid Functions


evaluateFunction() executes a function in each row in a grid, using the grid fields in operations such as + (addition), - (subtraction), * (multiplication), / (division), and % (remainder). The formula can also use ( ) to group together operations.

array evaluateFunction(array gridName, string Expression)


  • grid gridName: The input grid.
  • string Expression: The input expression for the operation to be done in the grid fields. The expression must always be enclosed within double quotes, otherwise a fatal error will occur.

Return Value:
This function returns an associative array of associative arrays, which is how grids are internally stored in ProcessMaker.


MyGrid = ( [name] [salary] [discount] [total] [1] ( 'ana', 1000, 100, 0 ) [2] ( 'erik', 2000, 0, 0 ) [3] ( 'jessi', 1200, 400, 0 ) [4] ( 'naira', 2000, 0, 0 ) )

The following function is executed, which subtracts the 'salary' field from the 'discount' field in each row and assigns the result to the 'total' field:

@=MyGrid = evaluateFunction(@=MyGrid, "@#total = @#salary - @#discount");

The result will be the following grid:

MyGrid = ( [name] [salary] [discount] [total] [1] ( 'ana', 2000, 100, 1900 ) [2] ( 'erik', 2000, 0, 2000 ) [3] ( 'jessi', 1200, 400, 800 ) [4] ( 'naira', 2000, 0, 2000 ) )


orderGrid() sorts a grid based on a specified field in ascending or descending order.

array orderGrid(array gridName, string field, string criteria='ASC')


  • array gridName: A grid, which is a numbered array containing associative arrays with field names and their values, and has to be set like this "@=".
  • string field: The name of the field by which the grid will be sorted.
  • string criteria: Optional parameter. The order can either be 'ASC' (ascending) or 'DESC' (descending). If not included, 'ASC' will be used by default.

Note: The result of this function has to be saved in a grid to see the sorted information; it can be saved in the same grid or in another grid.


If your grid is like this:

MyGrid = ( [firstname][lastname] [1] ( 'erik', 'ortiz' ) [2] ( 'ana', 'castro' ) [3] ( 'naira', 'jimenez' ) [4] ( 'jessica', 'martinez') )

Then sort the grid by the 'firstname' field:

@=MyGrid = orderGrid(@=MyGrid, 'firstname', 'ASC');

The result will be the following grid:

MyGrid = ( [firstname][lastname] [1] ( 'ana', 'castro' ) [2] ( 'erik', 'ortiz' ) [3] ( 'jessica', 'martinez') [4] ( 'naira', 'Jimenez' ) )


Available Version: As of ProcessMaker 3.5.0.

PMFTotalCalculation() allows number grid to calculate a total of the row or column defined by a calculation type.

array PMFTotalCalculation()(@= gridVar001, string COLUMN, string FUNCTION)


  • @= gridVar001: The grid ID.
  • string COLUMN: The column control ID.
  • string FUNCTION: The calculation types that are:
    • sum: Calculates the sumatory of the values supplied wthin a row o a column.
    • average: Calculates the average of values supplied within a row o a column.
    • median: Calculates the median of the values within a row or a column.
    • minimum: Displays the minimum value within a row or a column.
    • maximum: Displays the maximum value within a row or a column.
    • standardDeviation: Calculates the grand total using standard deviation as the standard deviation of the values within a row or a column.
    • variance: Calculates the grand total using variance, not the variance of the rows and columns in which they reside but rather the underlying data behind the row or column.
    • percentile: Calculates the average percentile of all values within the rows and columns on screen.
    • count: Counts how many values displayed in the rows and columns in the view.
    • countDistinct: Displays the number of distinct values within the rows and columns on screen.

Return Value:
A numeric total amount. If the function parameter is percentile, the return value is an array.

By default the floating point number for digits is 10, but this can be setup in the env.ini file using the pmftotalcalculation_floating_point_number parameter.

Note: After calculations are made and if there is a new element within the grid, the total field displays NaN and the total value is not updated when there is a new row value. The elements within the column need to be validated to avoid being considered NaN. When a value field from the column is updated, the total calculation with the function is defined.