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.