I’ve created a custom field in “Item” doctype and using client side script to populate the data on the fly.
frappe.ui.form.on("Item", {
refresh: function(frm) {
var price_list;
frappe.call({
method: "frappe.client.get",
args: {
doctype: "Item Price",
filters: {
"item_code": frm.doc.item_code,
"price_list":"Standard Selling"
}
},
callback(r) {
if(r.message) {
price_list= r.message;
frm.set_value("current_selling_price", price_list.price_list_rate);
refresh_field("current_selling_price");
}
}
});
}
});
The issue is, when it can’t find the document, the page will pop up an error “No document found for given filters”.
How do I suppress the pop up error?
Here’s the console error log
jquery.min.js:4 POST http://localhost:8080/ 417 (EXPECTATION FAILED)
desk.min.js:1363 Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 56, in application
response = frappe.handler.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
data = execute_cmd(cmd)
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 52, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 914, in call
return fn(*args, **newargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/client.py", line 43, in get
frappe.throw(_("No document found for given filters"))
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 320, in throw
msgprint(msg, raise_exception=exc, title=title, indicator='red')
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 310, in msgprint
_raise_exception()
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 283, in _raise_exception
raise raise_exception(encode(msg))
ValidationError: No document found for given filters
Thanks
Solved.
I use get_value instead.