How to fetch value from one doctype to another doctype

Hi @BalaV,

Please apply the client script for it.
Here, we share the syntax, so please set your doctype and field according.

frappe.ui.form.on('SecondDocType', {
    refresh: function(frm) {
        // Fetch values from FirstDocType based on prospect_id
        frappe.db.get_value('FirstDocType', {'prospect_id': frm.doc.prospect_id}, 'field_name', function(value) {
            // Update field in SecondDocType with the fetched value
            frm.set_value('field_name', value.field_name);
            // Repeat the above line for other fields you want to populate
        });
    }
});

I hope this helps.
Thank You!

2 Likes