How to fetch a field value in another doctype

Hi @SonalD,

Please try it.

frappe.ui.form.on("Sales Invoice", "shipping_address_name", function(frm) {
    
    frappe.db.get_value("Address", {"name": frm.doc.shipping_address_name}, "state", function(value) {
        // state is the address master field. otherwise, you can also choose gst_state.
        var get_state = value.state;
        // if choose gst_state then change the above value like value.state -> value.gst_state
        console.log("State ---------->",get_state);
        
        frappe.db.get_value("Seed License No", {"state": get_state}, "seed_license_no", function(value) {
            frm.doc.seed_license_no = value.seed_license_no;
            console.log("Seed License No ---------->",frm.doc.seed_license_no);
            
        });
    });
});

Then reload and check it.

Thank You!

2 Likes