ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Auto populate child table field from doc field


#1

i use below script to auto populate debit field in account table in journal entry doc form custom field called amount in a journal entry doc but not working

frappe.ui.form.on(“Journal Entry Account”, {
debit_in_account_currency: function(frm, cdt, cdn) {
var row = frappe.get_doc(cdt, cdn);
if(debit_in_account_currency) {
row.debit_in_account_currency = doc.amount;
refresh_field(“debit_in_account_currency”, cdn, “accounts”);
} else {
this.frm.script_manager.copy_from_first_row(“accounts”, row, [“debit_in_account_currency”]);
}
}});


#2

Were you able to solve this? here is how i would do it

frappe.ui.form.on(“Journal Entry”,
{
amount:function(frm) {
// accounts is the name for Journal Entry Account
$.each(frm.doc.accounts || [], function(i, d) {
if(!d.debit_in_account_currency) d.debit_in_account_currency = frm.doc.amount;
});
refresh_field(“accounts”);
},
});