Dear Community,
When Estimation is created and create quotation via estimation.
If the Estimation is Customer the Party (Dynamic Link) auto fetch the customer name and other details but if the estimation is Lead it only change the Party label as Lead but not fetch.
Estimation:
Quotation:
Estimation Doctype:
Quotation Doctype:
It fetch other details but not lead, but it works on customer.
Even i tried code,
frappe.ui.form.on('Quotation', {
before_save: function(frm) {
if (frm.doc.estimation) {
frappe.db.get_doc('Estimation', frm.doc.estimation)
.then(doc => {
// Set quotation_to and party_name based on estimation_for
if (doc.estimation_for === 'Customer' && doc.customer) {
frm.set_value('quotation_to', 'Customer');
frm.set_value('party_name', doc.customer);
} else if (doc.estimation_for === 'Lead' && doc.lead) {
frm.set_value('quotation_to', 'Lead');
frm.set_value('party_name', doc.lead);
// Fetch Lead details and assign to party_name
frappe.db.get_value('Lead', doc.lead, 'lead_name', (r) => {
if (r && r.lead_name) {
frm.set_value('party_name', r.lead_name);
}
});
} else {
console.log('No valid customer or lead found in the estimation document.');
}
})
.catch(error => {
console.error('Error fetching estimation document:', error);
});
}
}
});
Can you help how to solve this issue.
Thanks in Advance