Custom script in child table

Hello I’m trying to set values to fields in a child table but it is not working… Below is the child table

cur_frm.cscript.units=function(doc){
if(doc.rate != null && doc.units !=null){
var cost = doc.rate * doc.units;
cur_frm.set_value(“cost”, cost);
refresh_field(“cost”)
}
}

units, cost and rate are fields in the child table… I tried this cutom script for the child table doctype but it is not working, kindly help out

Try this:

cur.frm.cscript.child_table_field_name=function(doc,cdt,cdn)
{
var d=locals[cdt][cdn]
var cost_value=d.rate * d.units;
d.cost=cost_value;
refresh_field(“child_table_name”);
}

3 Likes

Thanks a lot, it worked!