0

I'm new to ProcessMaker and we were tasked to practice on computational processing using Javascript in ProcessMaker.

So I looked up the documentation, and I tried creating a dynaform that computes the total when you input a price and quantity.

I pasted the code I had in the "javascript" section, but when I try to preview it it just loads forever.

This is the code that I used:

 function calculateTotal() {
   getField("sTotal").value = parseFloat(getValueById("basePrice")) - 
   parseFloat(getValueById("Qty"));
}

leimnud.event.add(getField("basePrice"), 'click', calculateTotal);
leimnud.event.add(getField("Qty"), 'click', calculateTotal);

Answers would be really appreciated thanks.

  • Are you sure calculateTotal is getting called? Try adding a console log inside it – juvian Jun 21 '17 at 17:33
  • i now think that what's is that i used "leimnud". what is the proper parameter to use? – Alex Espiritu Jun 21 '17 at 17:36
  • http://wiki.processmaker.com/3.0/JavaScript_in_DynaForms#Tying_Code_to_Events see Setting an event handler – juvian Jun 21 '17 at 17:39
  • Leimnud is only for ProcessMaker 2.x. If you are using ProcessMaker 3, that would indeed throw an error. What are you getting back from the console? Any errors? – Ethan Presberg Jun 23 '17 at 15:14

2 Answers2

2

Indeed as Ethan Presberg mentioned, the Leimnud framework is only supported up to ProcessMaker 2.x.

For ProcessMaker 3.x you can use JQuery to trigger the onclick event by adding a button control like this:

$("#button1").find("button").on("click", calculateTotal();

You can find more information about using JQuery with ProcessMaker 3.x's Dynaforms in our Wiki here: http://wiki.processmaker.com/3.2/JavaScript_Functions_and_Methods

Best regards,

Arturo A. Robles

0

Use below code

In dyna form add two text boxes and button

@@quantity
@@price
@@getTotalPrice

Now paste below code in JavaScript section:

$('#getTotalPrice').find('button').on("click", getTotal());

function getTotal()
{
var quantity = $('#quantity').getValue();
var price = $('#price').getValue();
var total = quantity * price;
}

alert (total);

If you want to assign this value to variable then create another variable totalPrice

$('#totalPrice').setValue(total);

Hope you understand.