1

I am trying to get and put last four fields value to my new created record from the latest created in my custom doctype, No luck working the client side scripting in ERPNEXT 13.

I need this to calculate the difference between today and yesterday value, ie:

resultfield = fieldnew1 - field1

Here My Client Script:

frappe.ui.form.on("Monitoring", {
    "refresh": function(frm) {
        frappe.db.get_list("Monitoring", {fields: ['*'], order_by: "creation desc", limit: 1}).then((result) => {
            frm.set_value({"fieldnew1": result.field1, "fieldnew2": result.field2,"fieldnew3": result.field3, "fieldnew4": result.field4 })
            frm.save();
        })
    }
});

What I want is to automatically fill the field value.

This is the Sample Result

Michelle
  • 11
  • 3

1 Answers1

-1
frappe.ui.form.on('FU Daily Report', {
    setup: function(frm){
        
    },
    // , creation: ["<", frm.doc.creation]
    fetch_records: function(frm) {
        frappe.db.get_list("FU Daily Report", {
            filters: {
                date: ["<", frm.doc.date]
            }, 
            fields: ["name", "rm_os", "rm_ics", "fg_os", "fg_ics"],
            order_by:'date desc'
            }).then(doc => {
            frm.set_value({
                "ref_report": doc[0].name,
                "rm_os": doc[0].rm_ics,
                "fg_os": doc[0].fg_ics
            });
            frappe.msgprint("Last Record Fetched From " + doc[0].name);
        });
    }
})
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 06 '23 at 20:02