Custom Script in List View not working

Hello,

I have this code as a Custom Script:

frappe.ui.form.on("Item Log", {
    onload: function(frm) {
        $.ajax({
            url: 'api/resource/Employee/?fields=["employee_name"]&filters=[["Employee","company_email","=","'+frm.doc.owner+'"]]',
            beforeSend: function() {
        cur_frm.set_value("usuario", __("Loading..."));
        },
            success: function(res) { 
                if (res.data.length > 0) {
                    if(res.data[0].employee_name != undefined) {
                        cur_frm.set_value("usuario", res.data[0].employee_name);
                    } else {
                        msgprint(__("Employee name not found!"));
                        itemLogReset();
                    }
                } else {
                    msgprint(__("Employee not found! The Employee need an valid mail of companny."));
                    itemLogReset();
                }
            }
        });
    },
    after_save: function() {
        frappe.set_route("List", "Item Log");
    }
});

cur_frm.cscript.barcode = function(doc, cdt, cdn) {
    var d = locals[cdt][cdn];
    if(d.barcode!="") {
        $.ajax({
            url: 'api/resource/Item/?fields=["name"]&filters=[["Item","barcode","=","'+d.barcode+'"]]',
            beforeSend: function() {
        cur_frm.set_value("product", __("Loading..."));
        },
            success: function(res) { 
                if (res.data.length > 0) {
                    if(res.data[0].name != undefined) {
                        cur_frm.set_value("product", res.data[0].name);
                    } else {                        
                        msgprint(__("Product Name not exists!"));
                        itemLogReset();
                    }
                }else {
                    msgprint(__("Product not found for this barcode!"));
                    itemLogReset();
                }
            }
        }); 
    }
}

function itemLogReset() {
    cur_frm.set_value("barcode", "");
    cur_frm.set_value("product", "");
}

When I access “new row full page”, this script works. But, When I load a new row by “modal” (Quick entry in listview), this code not working.

Somebody know why? or What i need call?

Thanks

Disable Quick Entry for this DocType

@rmehta, thank you for you help. My objective is show Quick Entry. But my custom script not working, or not called when is “showed” the quick entry. That is my problem.

Any update on this issue?

1 Like