Try ERPNext Buy Support Partners Foundation

Need help for Custom Client script

In my custom app, while fetching value through client script not working, error 404.

Client Script

frappe.ui.form.on(‘Labour Bill Payment’, ‘btnload’, function(frm) {

frappe.call({
	method: "cons.construction.client.get_item_details",
	args: {"item_code":frm.doc.labour},
	callback: function(r) {
	if(r.message) {
	   alert(r.message.lab_mc)
	}
}

});

Py file

@frappe.whitelist()
def get_item_details(item_code):
item = frappe.db.sql(""“select lab_mc, lab_type,lab_ma,lab_sc
from tabLabour where name = %s”"", item_code, as_dict=1)
return item.lab_mc

Try by adding [0][0] at the end of the frappe.db.sql()

Eg:
item = frappe.db.sql(""“select lab_mc, lab_type,lab_ma,lab_sc
from tabLabour where name = %s”"", item_code, as_dict=1)[0][0]

Is that path correct? Try changing it. Maybe “construction.client.get_item_details”.

I tried with adding [0][0]at the end but the result shows in the console as
console.trace()
at Anonymous function (http://157.245.96.234:8007/assets/js/desk.min.js?ver=1574682464.0:1:59991)
at i (http://157.245.96.234:8007/assets/frappe/js/lib/jquery/jquery.min.js:2:27146)
at j.fireWith (http://157.245.96.234:8007/assets/frappe/js/lib/jquery/jquery.min.js:2:27856)
at z (http://157.245.96.234:8007/assets/frappe/js/lib/jquery/jquery.min.js:4:11628)
at Anonymous function (http://157.245.96.234:8007/assets/frappe/js/lib/jquery/jquery.min.js:4:15458)

yes, Path is correct.

Can you check what you are getting in r.message ?
Also check data returning from query in py file.