Field recipients not found

frappe.ui.form.on(‘Quotation’, {
get_email_recipients: function(frm) {
let contact_person = frm.doc.contact_person;
console.log(“Contact Person:”, contact_person);

    // Fetch the contact document to get the emails from the child table
    if (contact_person) {
        frappe.db.get_doc('Contact', contact_person)
            .then(doc => {
                if (doc && doc.email_ids && doc.email_ids.length > 0) {  // Check if there are emails
                    let email = doc.email_ids[0].email_id; // Get the first email
                    console.log(email);

                    // Set the recipients field with the first email
                    frm.set_value('recipients', email);

                    frm.refresh_field('recipients'); // Refresh the recipients field
                } else {
                    console.log("No email addresses found for this contact.");
                }
            })
            .catch(err => {
                console.error("Error fetching contact:", err);
            });
    }
}

});

i Want to filter email based on customer and add in email pop then showing error Field recipients not found.

remove this line and check it.

not working

i want to add default mail in to

share the full screenshot and elaborate the process, community users will help.

i want to add a default email address in the “to” field

It will come automatically if the quotation doctype has an email. (without code).

What vesrion of ErpNext are you using? Currently in V15 The receipient email field automatically as long as the doctype has an email field and the party in question(customer/supplier) has an email in their details.They are fetched automatically into the doctype.