Fetch Value of a custom filed into child table column

I have Parent Doctype name OFFER FEIPL EX
Child Table name - Offer Item (field name = items)

Parent Doc has a customised field named “factor”
Offer item table has a column or field named “factor”
If the offer item table has 4 - 5 rows or n number of rows in it, then the field factor in child table must show the factor from parent doc in all rows. since this is going to be multplication ahead.

Whenever the factor value changes in parent doc type, then the value must change in the child table too.

frappe.ui.form.on(“Offer Item”,{
items_add: function (frm,cdt,cdn){
Var child= locals[cdt][cdn]
child.factor = frm doc.factor
frm.refresh_fields(“items”)
}
})
frappe.ui.form.on(“OFFER FEIPL EX”,{
factor: function (frm,cdt,cdn){
Var child= frm.doc.items
child.forEach(item=>{
itm.factor = frm.doc.factor
})
frm.refresh_fields(“items”)
}
})

1 Like

Praveen Kumar ji

Many Many thanks…!! This is working…!

Do we have to use the complete same script if we need to fetch few more fields on same child table or we can add new line in same script?

Yes,
frappe.ui.form.on(“Offer Item”,{
items_add: function (frm,cdt,cdn){
Var child= locals[cdt][cdn]
child.factor = frm doc.factor
child.new_field_name1 = from.doc.new_field1
.
.
.
.
frm.refresh_fields(“items”)
}
})
frappe.ui.form.on(“OFFER FEIPL EX”,{
factor: function (frm,cdt,cdn){
Var child= frm.doc.items
child.forEach(item=>{
itm.factor = frm.doc.factor
child.new_field_name1 = from.doc.new_field1
.
.
.
.
})
frm.refresh_fields(“items”)
}
})

1 Like