Hi,
I have tried fetching the field from the other doctype’s child table to put to another doctype’s child table. But it can’t seem to find each other.
I have made a table under the Purchase Order which is “payable_table” and I want that to be read only because I want to fetch the rows from another table which is located at Supplier (“bank_account”).
I have tried the below but it seems that it can only fetch fields outside the Supplier’s table.
cur_frm.add_fetch(“supplier”, “payee_name”, “payee_name”);
cur_frm.add_fetch(“supplier”, “account_number”, “account_number”);
Hope you could help me with this. Thank you.
@kelscey90
add_fetch("link fieldname", "source fieldname", "target fieldname")
You can’t do it using add_fetch as it only works on link field.
So you have to try it using getting and setting the value using db.get_value and db.set_value.
@KanchanChauhan Thanks a lot for this one very informative. However It doesn’t seem to work for me or I did something wrong? Could you help me out?
Here’s the code:
frappe.ui.form.on(“Loan Item”, “onload”, function(frm, cdt, cdn, doc, dt, dn){
frm.add_fetch(“item_code”, “description”, “description”);
frm.add_fetch(“item_code”, “item_name”, “item_name”);
frm.add_fetch(“item_code”, “stock_uom”, “uom”);
frm.add_fetch(“item_code”, “item_group”, “item_group”);
frm.add_fetch(“item_code”, “brand”, “brand”);
frm.add_fetch(“requested_by”, “Non-Alcon Personnel”, “non_alcon_personnel”);
frm.add_fetch(“tc_name”, “terms”, “terms”);
frm.add_fetch(“customer”, “company_name”, “company_name”);
frm.add_fetch(“customer”, “lead_name”, “contact_person”);
frm.add_fetch(“customer”, “address”, “company_address”);
frm.add_fetch(“customer”, “mobile_no”, “contact_number”);
});
frappe.ui.form.on(“Purchase Order”, “Trigger”, function(frm) {
frappe.model.with_doc(“Supplier”, frm.doc.trigger, function() {
var tabletransfer= frappe.model.get_doc(“Supplier”, frm.doc.Trigger)
$.each(qmtable.Payable Table A, function(index, row){
d = frm.add_child(“Payable Table”);
d.payee_name = row.payee_name;
d.account_number = row.account_number;
cur_frm.refresh_field(“Payable Table”);
})
});
});
@shivkumar could you set an example for the db.value?