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

Problem with set value in child table

custom_script

#1

I am trying to set values to a child table but it is not working. Here’s my code

      var d = res.message
      d.forEach( function(row,v) {
          frappe.model.set_value(row.doctype, row.name , "category", d[v]['category'])
          frappe.model.set_value(row.doctype, row.name , "name2", d[v]['name2'])
          frappe.model.set_value(row.doctype, row.name , "min", d[v]['min'])
          frappe.model.set_value(row.doctype, row.name , "max", d[v]['max'])
        })
      cur_frm.refresh_fields();
    }
 

Although the loop is working correctly but value is not getting pushed to rows.


#2

@nikzz try this :

  var d = res.message
  d.forEach( function(row,v) {
       var new_row = frm.add_child("child_table_name");
            new_row.category = d[v]['category'];
            new_row.name2 = d[v]['name2'];
            new_row.min = d[v]['min'];
            new_row.max = d[v]['max'];       })
  refresh_field("child_table_name");
}

#3

Thanks


#4