Handling not found notification


I have a custom “Plasma” field in the Purchase Receipt doc. When this field is filled in, the warehouse field will also be filled automatically. However, when I erased the contents of the plasma, it said not found.

How do you handle this error so that when the plasma field has no content, this notification does not appear?

Here is my javascript custom field code, i try to add else conditional but it seems not working

frappe.ui.form.on('Purchase Receipt', {
    plasma: function (frm) {
            method: "frappe.client.get",
            args: {
                doctype: "Plasma",
                name: frm.doc.plasma,
            callback(r) {
                if (r.message) {
                    frm.set_value('set_warehouse', r.message.warehouse);
                } else {
                    frm.set_value('set_warehouse', 'none');

You can use if before frappe.call, i think.
if (frm.doc.plasma) { //code frappe.call here }
else { //code when field plasma is empty
console.log("Plasma is empty") }

That’s it :grin:

hi @antzforwork

thank for your solution