Clear fields of child table

I have a custom child table for the required items in a custom doctype. When I select an item to manufacture, the required items will be inserted in the child table. If I select a new item to manufacture, the child table must be updated to clear the fields and insert the new required items in it.

Currently, this JS custom script performs the task of inserting the required items:

bom_no: function (frm) {
    frappe.model.with_doc("BOM", frm.doc.bom_no, function() {
        var tabletransfer = frappe.model.get_doc("BOM", frm.doc.bom_no);

        $.each(tabletransfer.items, function (index, row) {
            d = frm.add_child("required_items");
            d.item_code = row.item_code;
            d.source_warehouse = row.source_warehouse;
            d.item_name = row.item_name;
            d.description = row.description;
            d.available_qty_at_source_warehouse = row.qty;
            d.cost = row.rate;

What I do not know is how to clean the fields of the child table when a list of required items is reinserted.
How can I do it?

Hi vazdan,

The answer is here.


Thank you very much @Rene_Mailloux!
I have it solved :blush: