Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By bilalk
#794454
hi,

i want to ask something about formula. i have a grid 3 textbox. textbox1*textbox2=textbox3 . its my formula. but i want to average after 2 letter like" 15471.9399999999" to "15471.94" . how can i do that for each line for grid?
Attachments
math.png
math.png (4.39 KiB) Viewed 7092 times
By bilalk
#794479
atuly7 wrote:See this topic
http://wiki.processmaker.com/3.0/Grid_C ... s_in_grids

It will work for your query.
Regards,

Ty for replyi

i want ask one more question about formula its really hard for me. i checked wiki and couldn't find anything.

there is a image all variable showing.

K variable is out of grid,
All other variables are inside grid,

i need this formulas,

for C = K / (A1*B1+A2*B2+A3*B3...)
for D1= B1 * C1

thank you for help
Attachments
math.png
math.png (14.63 KiB) Viewed 7080 times
User avatar
By amosbatto
#794504
bilalk wrote:there is a image all variable showing.

K variable is out of grid,
All other variables are inside grid,

i need this formulas,

for C = K / (A1*B1+A2*B2+A3*B3...)
for D1= B1 * C1
Your JavaScript code would be something like this:
Code: Select all
function roundToFixed(_float, _digits) {
  var rounder = Math.pow(10, _digits);
  return (Math.round(_float * rounder) / rounder).toFixed(_digits);
}

$("form").setOnchange(function(field, newVal, oldVal) {
  var totalRows = $("#invoiceList").getNumberRows();
  var k = parseFloat($("#k").getValue());
  if (isNaN(k)) {
     k = 0;
  }
  var runningTotal = 0;

  for (var i = 1; i <= totalRows; i++) {
    a = parseFloat($("#invoiceList").getValue(i, 1));
    b = parseFloat($("#invoiceList").getValue(i, 2));
    
    //make sure the user entered valid values:
    if (isNaN(a) || isNaN(b)) {
      runningTotal += 0; //add nothing if invalid input
      
    }
    else {
      runningTotal += a * b;
    }
    c = k / runningTotal;
    d = roundToFixed(b * c, 2);
    c = roundToFixed(c, 2);    
  
    $("#invoiceList").setValue(c, i, 3);
    $("#invoiceList").setValue(d, i, 4);
  }
});
By bilalk
#794523
amosbatto wrote:
bilalk wrote:there is a image all variable showing.

K variable is out of grid,
All other variables are inside grid,

i need this formulas,

for C = K / (A1*B1+A2*B2+A3*B3...)
for D1= B1 * C1
Your JavaScript code would be something like this:
Code: Select all
function roundToFixed(_float, _digits) {
  var rounder = Math.pow(10, _digits);
  return (Math.round(_float * rounder) / rounder).toFixed(_digits);
}

$("form").setOnchange(function(field, newVal, oldVal) {
  var totalRows = $("#invoiceList").getNumberRows();
  var k = parseFloat($("#k").getValue());
  if (isNaN(k)) {
     k = 0;
  }
  var runningTotal = 0;

  for (var i = 1; i <= totalRows; i++) {
    a = parseFloat($("#invoiceList").getValue(i, 1));
    b = parseFloat($("#invoiceList").getValue(i, 2));
    
    //make sure the user entered valid values:
    if (isNaN(a) || isNaN(b)) {
      runningTotal += 0; //add nothing if invalid input
      
    }
    else {
      runningTotal += a * b;
    }
    c = k / runningTotal;
    d = roundToFixed(b * c, 2);
    c = roundToFixed(c, 2);    
  
    $("#invoiceList").setValue(c, i, 3);
    $("#invoiceList").setValue(d, i, 4);
  }
});

ty for help amos,

but this formula is not same as i need. because "C" variable getting bigger and the last C variable in grid is what i need. i added an attachment showing what i need.

in example
c variable is ratio between are real weight and expected weight,
d variable is each piece weight became from real weight * ratio
Attachments
Adsız.png
Adsız.png (25.21 KiB) Viewed 7064 times
By bilalk
#794530
Amos,

btw i think there is a bug about this one. there is a image shows you about it. after 3 lines formula stop calculating. when i add new line it calculated one more time and the last one stay forever. i have tried 7-8 times it stoped each time.
Code: Select all
function setIndependent (newVal, oldVal) {
  var oGrid = $("#SD02"); 
  for (var i = 1; i <= oGrid.getNumberRows(); i++) {
    oGrid.setValue(newVal, i, 1);
  }   
}
$("#SD01").setOnchange(setIndependent);
setIndependent($("#SD01").getValue(), '');
$("#SD02").onAddRow(function(aNewRow, oGrid, rowIndex) {
    aNewRow[2].setValue( $("#SD01").getValue() );
})

$("#button0000000001").find("button").on("click" , function() {
    $("#SD02").saveForm();
} );

function roundToFixed(_float, _digits){
  var rounder = Math.pow(10, _digits);
  return (Math.round(_float * rounder) / rounder).toFixed(_digits);
}


$("form").setOnchange(function(field, newVal, oldVal) {
  var totalRows = $("#SD02").getNumberRows();
  var totalCost1 = parseFloat($("#SD02").getSummary("SDG04"));
  var totalCost2 = parseFloat($("#SD02").getSummary("SDG06"));
  for (var i = 1; i <= totalRows; i++) {
    price   = parseFloat($("#SD02").getValue(i, 5));
    taxRate = parseFloat($("#SD02").getValue(i, 6));
    tax     = price * taxRate;
    if (isNaN(tax)) { 
      tax = '';
      total = '';
    }
    else { 
      tax     = roundToFixed(tax, 2);
    }  
    $("#SD02").setValue(tax,   i, 7);
    $("#SD22").setValue(totalCost1);
    $("#SD23").setValue(totalCost2);
  }
});
this is my javascprit code. Generally its only the last one getting failure
Attachments
Adsız.png
Adsız.png (10.36 KiB) Viewed 7058 times
By bilalk
#794558
amosbatto wrote:I can't debug it without your form. Export your DynaForm and post the json file here.

here in attachment, can you check it above situation too?
Attachments
(55.74 KiB) Downloaded 285 times
User avatar
By amosbatto
#794583
Bilal, I am not seeing any problems in your form in my installation of PM:
GridSumming.png
GridSumming.png (24.67 KiB) Viewed 7037 times
The tax field is calculated for each row. I have added up to 10 rows and deleted rows and it always works. I'm using PM 3.2 with Firefox 51 (in Debian 8.4). What version of PM and what web browser are you using?
By bilalk
#794592
amosbatto wrote:Bilal, I am not seeing any problems in your form in my installation of PM:
The tax field is calculated for each row. I have added up to 10 rows and deleted rows and it always works. I'm using PM 3.2 with Firefox 51 (in Debian 8.4). What version of PM and what web browser are you using?
i am using PM 3.0.1.8 ( cant upgrade to 3.2 due to transfer data i am desperatle waiting your answer there viewtopic.php?f=40&t=711110&p=793928#p794057) and Using chrome as web browser on windows server 2012 . it doesnt calculated last one, sometimes 2-3 lines doesnt calculated either.
Adsız.png
Adsız.png (36.08 KiB) Viewed 7030 times
User avatar
By amosbatto
#794601
I tried your form in Chrome 52 with PM 3.2 and it works fine. However, when I imported your process into PM 3.0.1.8, I do see the problem in Chrome when using the Debugger (press F12). The grid.setValue() and grid.getNumberRows() methods generate the error: Uncaught RangeError: Maximum call stack size exceeded
setValueJSError.png
setValueJSError.png (66.13 KiB) Viewed 7018 times
It appears to only be a problem with Chrome, which can't handle long arrays. See:
https://stackoverflow.com/questions/183 ... -max-apply

My recommendation is to either use PM 3.2 or tell your users to not use Chrome.

Sorry about not being able to upgrade PM on Bitnami, but Bitnami installations are not meant for production use. People complained that it was too hard to try out PM, so the developers asked Bitnami to create an easy installer for people who didn't want to do a manual installation just to try the program. Unfortunately, Bitnami is not the same as a manual installation, so the upgrade scripts don't work. The developers never intended Bitnami installations to be used for production. You can file a bug report asking for an upgrade script for Bitnami. The developers don't think that anyone needs it, so they need to hear from many users that it is needed.

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]