Save grid summary as variable

From pmusers
Jump to: navigation, search

This example shows how to save the sum or average of grid's column as a case variable.

Create a hidden field with the ID and variable "gridSum". Then add this JavaScript to your Dynaform to copy the grid's sum to the "gridSum" field when the Dynaform is submitted:

var formId = $("form").prop("id");
$("#"+formId).setOnSubmit( function() {
     var sum = $("#myGrid").getSummary("myGridField");

Where "myGrid" is the ID of the grid and "myGridField" is the ID of the grid field which is summed.

Then, the case variable "gridSum" will saved to the case when the Dynaform is submitted. This variable can be displayed in a subsequent DynaForm which has a field associated with the variable "gridSum". This variable can also be used in a condition in a gateway as @#gridSum (if a decimal number) or @%gridSum (if an integer).