How to fetch a field value in another doctype

Thank you so much!!!


this is my code …it showing me some error


this is the error


this is my seed license no doctype

Please, check the fields “realname”. Put your mouse pointer overthe field and you will see this.

I think that this name maybe is wrong …

'filters': {'**your_state_field**' ...


it is same

I mean the state field name on the other doctype.


given the field name as in seed license no. still not working.

Ok, do you see any error in the console?

No i didnt see any error

Well … at this point, it’s no so easy to determine what is happening here … How the user set the value of shipping_address_state? Manually? Or is “inherited” from the address? Maybe this field don’t trigger the update … Try to remove the “//” before console.log … This way you will see if the change is detected

Hi avc…i want to calculate data in child table if sales invoice.


this is my script i want to calculate packing total as qty*packing expense but the script is not working. please help!!


this is my child table in sales invoice

Hi:

Please, open different thread for this question. Is unrelated to the topic.

Thanks.

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

it get updated automatically whenever we select customer.

thanks NCP it is working.

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);
        
    });
});

});

@NCP I want to fetch the cost from the subscription plan under the subscription plan detail. Below is the way I’m doing but the way fetch from is not working. While option is working fine but I need the cost only.

Hi @Syed_Saad_Imam,

please check it.
https://docs.erpnext.com/docs/v14/user/manual/en/customize-erpnext/articles/how-to-add-master-link-and-fetch-data-from-the-same

Please create a new Topic.

And do not tag any user.
The community is large if we have an answer to it then will reply to it.
otherwise, anyone can answer you.

Have a good day.
Thank You!

Thank you so much for your prompt feedback.

“And do not tag any user.” Yes sure, will take care of this next time.

Thank you.