Event is triggered multiple times

Hi,

i have created custom controller class like SalesController, in this class i have coded event listner for child table field change:

my_custom_app.my_custom_app.MyController = frappe.ui.form.Controller.extend({
    my_field: function (doc, cdt, cdn) {
         console.log("is triggered");
    },
});

This is triggered twice.

I tried also set event listener in setup:

my_custom_app.my_custom_app.MyController = frappe.ui.form.Controller.extend({
    setup: function () {
        frappe.ui.form.on("My Child Doctype", "my_field",  $.proxy(function(frm, cdt, cdn) {
   		     console.log("is triggered");
	    }, this));
    },
});

This is triggered 4 times.

Event is triggered properly in both versions of code, but is triggered multiple times.

What Am I doing wrong? THANKS

1 Like

Hi Janecek,
I am facing the same problem,
have you found the solution?

Hi, I am not sure. Its long time ago.

1 Like

The the problem of field you are using.

  1. make you your field is the same data type if Int or Float .
  2. Frappe will trigger two times , the reason is
  • you input 1 (onchange call)
  • frappe/erpnext will parse to float (1.00) (onchange call second time)
1 Like