Share ideas, ask questions, and get feedback about developing for ProcessMaker
Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
#785951
Hi,
I have a form with 3 grids. Each grid has a subtotal. I am trying to calculate a Grand Total (subtotal1 +subtotal2+subtotal3).

I have the following javascript code written:

getField("SYS_GRID_AGGREGATE_adjuncts_adjunctsalary").onchange = calculate; //subtotal1
getField("SYS_GRID_AGGREGATE_fulltime_fulltimesalary").onchange = calculate; //subtotal2
getField("SYS_GRID_AGGREGATE_tempsvc_tempsvcsalary").onchange = calculate; //subtotal3

function calculate(){
var x = getField("SYS_GRID_AGGREGATE_adjuncts_adjunctsalary").value; //subtotal1
var y = getField("SYS_GRID_AGGREGATE_fulltime_fulltimesalary").value; //subtotal2
var z = getField("SYS_GRID_AGGREGATE_tempsvc_tempsvcsalary").value; //subtotal3
var r = x+y+z;
getField("totalpersonnel").value=r //grand total
}

I added the code by selecting the form properties and clicking on the javascript edit button.

Now when I preview the form I get the circling timer which never goes away and the form does not display??

Please Help....I am new to processmaker.
#785957
From your code, I assume that you are using ProcessMaker 2. The spinning circle means that you have an error in your JavaScript code.
First of all, define your event handler function before you reference it in the code. Also check if you misspelled one of the names of your fields. Remember that field names are case sensitive.

Another problem is that the summary fields for grids never fire an onchange event because the value of these fields are set by code, so your event handler function will never be executed. My suggestion is to add an onchange event handler to the form, so it will be fired every time any field in the form is changed:
Code: Select all
function calculate() {
  var x = getField("SYS_GRID_AGGREGATE_adjuncts_adjunctsalary").value; //subtotal1
  var y = getField("SYS_GRID_AGGREGATE_fulltime_fulltimesalary").value; //subtotal2
  var z = getField("SYS_GRID_AGGREGATE_tempsvc_tempsvcsalary").value; //subtotal3
  var r = parseFloat(x)+parseFloat(y)+parseFloat(z);
  getField("totalpersonnel").value=r;   //grand total
}
getField("totalpersonnel").form.onchange = calculate;

💥 Join the Exclusive Trading Community and Experie[…]

Briefly introduce the topic and provide context. S[…]

If you want to know the best technique to export P[…]

Nursing dissertation help topics

Home of Dissertations is the most used platform th[…]