Handling not found notification

Hi,

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) {
        frappe.call({
            method: "frappe.client.get",
            args: {
                doctype: "Plasma",
                name: frm.doc.plasma,
            },
            callback(r) {
                if (r.message) {
                    frm.set_value('set_warehouse', r.message.warehouse);
                    frm.refresh_field('set_warehouse');
                } else {
                    frm.set_value('set_warehouse', 'none');
                    frm.refresh_field('set_warehouse');
                }
            }
        });
    }
});

You can use if before frappe.call, i think.
So
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