ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Firing a event/function when changing any field value in doc


#1

Hi, I am stuck in a case, where every field is linked to other field, so changing one field value will impact other. so i would to write a script to fire a event when any field value is changed.


#2

Try writing that script on event on_update


#3

@root13F on_update event is not triggering.

In mycase I need to fire event when any field value is changed without save/updating the doc.


#4

Bump.


#5

Create a custom script with following code:

frappe.ui.form.on ('[your doctype here]', 'setup', function(frm){
    for (const fieldname of frm.meta.fields.map(x => x.fieldname)) {
        frappe.ui.form.on(frm.doctype, fieldname, function() {
          // your code here
        });
    }
});