Cur_frm.add_fetch

I am just starting to do Custom Script, and I can´t find out what is wrong. I tried for times like this:

cur_frm.add_fetch(‘employee’, ‘employee_name’, ‘nombre_completo’)
cur_frm.add_fetch(‘employee’,‘employee_name’,‘nombre_completo’)
cur_frm.add_fetch(“employee”, “employee_name”, “nombre_completo”)
cur_frm.add_fetch(“employee”,“employee_name”,“nombre_completo”)

The field nombre_completo is “Read Only” and in “Option” I write employee.employee_name. Someone can help me???

Can you add a little more detail of your problem? Did you define what triggers the fetch?

Something like this:

frappe.ui.form.on("DOCTYPE NAME", "employee", function(frm) {
    cur_frm.add_fetch('employee', 'employee_name', 'nombre_completo');


});

Thanks! I tried like this, but did not work:

frappe.ui.form.on(“project”, “employee”, function(frm) {
cur_frm.add_fetch(“employee”, “employee_name”, “nombre_completo”);

});

Try using a capital letter in Project.

Is this all in the main Doctype or are you using a child table?

Are you going into Administrator / Reload to make sure the script is called?

In the main Doctype, into Administrator, Reload each time, still do not work…I tried both; " and '.

Is “employee” a link field?

Are you trying to do something like this:

frappe.ui.form.on("Project", "employee",
function(frm) {
    frappe.call({
        "method": "frappe.client.get",
        args: {
            doctype: "Employee",
            name: frm.doc.employee
        },
        callback: function (data) {
            frappe.model.set_value(frm.doctype,
                frm.docname, "nombre_completo",
             data.message.employee_name
               )
            
        }
    })
});
5 Likes

Thank you very much!! I works!!