Ask questions about installing and configuring ProcessMaker 3

Moderator: amosbatto

By walshie1973
#783970
We are running Processmaker 3.0.0.5 and I have been trying to do a calculation of a grid field called Total (see below)
RecruitmentTests01.png
RecruitmentTests01.png (20.39 KiB) Viewed 846 times
If the "Required" field is checked, then the total should equal the cost field. If it is unchecked, then the amount should be 0.00. I would then like to use the sum of the "Total" field in other calculations on the Dynaform.

I have tried so many different ways of coding this, which haven't worked, so it would be pointless to even show any of it here.

Any suggestions how to do this in version 3.0?
By Vvladimir
#786657
Hi walsh 1973

Let you know that there is an option in Grids for the same Dynaform, you of the total according to the fields that you enter it, you attached a picture, hope I helped.

Greetings.

Best Regards,

Vladimir Vargas
Software Quality Engineer
ProcessMaker
Attachments
(72.63 KiB) Downloaded 12 times
By cpomares
#814231
Hi walshie1973,
As far as i understand, you want something similar to this:
Selection_004.png
Selection_004.png (20.23 KiB) Viewed 296 times
You can do it using JavaScript, here i show you the code i used:
Code: Select all
var sum =0;
for (var i=1;i<=$("#gridVar002").getNumberRows();i++){
	if($("#gridVar002").getValue(i,2) == "1"){
		$("#gridVar002").setValue((parseFloat($("#gridVar002").getValue(i,3))),i,4);
	}
	else{
  		$("#gridVar002").setValue(0,i,4);
    }
  sum=sum+$("#gridVar002").getValue(i,4);
}

$("#textVar002").setValue(parseFloat(sum));
Where "gridVar002" is the ID of the grid and "textVar002" is the ID of the final text box where i display the sum of the total.

Regards,
Carlos
By PipSqueak
#815645
Hi, I added setonchange, but this did not work.
Code: Select all
$("#form").setOnchange(function(field, newVal, oldVal) {  
var sum =0;
for (var i=1;i<=$("#gridQuotes").getNumberRows();i++){
	if($("#gridQuotes").getValue == "1"){
      	$("#gridQuotes").setValue((parseFloat($("#gridQuotes").getValue(i,2))),i,5);
     
	}
	else{
  		$("#gridQuotes").setValue(0,i,5);
    }
  sum=sum+$("#gridQuotes").getValue(i,5);
}

$("#textVar002").setValue(parseFloat(sum));
});
By amosbatto
#815663
PipSqueak,
You need to use the ID of the Dynaform, like this:
Code: Select all
var formId = $("form").prop("id");
$("#"+formId).setOnchange(function(field, newVal, oldVal) {  
  var sum = 0;
  for (var i = 1; i <= $("#gridQuotes").getNumberRows(); i++) {
    if ($("#gridQuotes").getValue == "1") {
      	$("#gridQuotes").setValue( (parseFloat($("#gridQuotes").getValue(i,2))), i, 5);
    }
    else{
       $("#gridQuotes").setValue(0,i,5);
    }
    sum = sum + $("#gridQuotes").getValue(i,5);
  }

  $("#textVar002").setValue( parseFloat(sum) );
});
Jalali Calendar

This topic says that this function " jdate fu[…]

messages

I just tried it in PM 3.2.1 and executing cron.p[…]

Session Expiration Issue

Hi .. I am using Mobile User Experience. In thi[…]

What happens if you change your HTML code to this?[…]