I am able to fetch data using cur_frm.add_fetch but this fetches something in a field say zzz ,now I want to fetch data in some other field from the data already fetched in zzz field . I tried the same cur_frm.add_fetch , this gets triggered only if I manually edit zzz field. It does not automatically the fetch data .
Many thanks for the reply , but what I want is the field zzz is a link field , my script fetches the exact data in zzz then from the zzz should fetch data and put it in ddd , how do I do that ?
The first code works perfectly and fetches the data in zzz field , but the second code does not work until I manually edit the data of zzz field . In this case could you please guide me @KanchanChauhan.
I dont want zzzâs value to appear in ddd field , zzz is the link field which gets filled automatically when I use this code cur_frm.add_fetch('item_code','ccc','zzz');
now my question is this code should work again with the data already fetched in the zzz field and fetch a data from bbb field in the zzz doc and put it in my ddd field.
To put simply cur_frm.add_fetch is not working for the second level .
// on js side
frappe.ui.form.on("**your Doctype**", "onload/whatever", function(frm) {
frappe.call({
method:"yourDoctype.method_name",
args:{"zzz":cur_frm.doc.zzz},
callback: function(r) {
if (r.message){
cur_frm.set_value("ddd_field",r.message[0].zzz)
}
}
});
}
// on py side
@frappe.whitelist()
def method_name(zzz):
//set this Query as per your requirement
data = frappe.db.sql("select name from `tabDoctype` where name = %s",zzz, as_dict=1)
return data
Many thanks for the help @shivkumar , but the above code is not working . I want to fetch bbb field and put that in ddd , where bbb is linked with zzz . Could you please guide me ?
Hi @Jitendra_Khatri1@shivkumar@KanchanChauhan@Nick , what I want is a javascript handler that allows me to call add_fetch() after my tcno field loads ( which is linked with the item module ) , both item doc and Tc doc have the same field cmill , I tried to accomplish with the help of @shivkumar with this code , but this is not working , please someone help me ,