Add child function 2 row at a time

i am trying to add new row with data in child table, but it adds 2 no of rows at a time,

scan_barcode: function(frm){
        var child = frm.add_child("item_table");
        child.receiving_id = frm.doc.scan_barcode;
        frm.set_value("scan_barcode",'');
        frm.refresh_fields("item_table");
    },

Hi @Praveenkumar
How about the second you try, is it become 3?

My suspect your’s Item Table is mandatory and have 1 row before you call event scan_barcode

To solve this issue

  1. you can add hooks on refresh to delete the row
  2. or check the table before inserting a new one

I found the solution,

 if(frm.doc.scan_barcode){
        var child = frm.add_child("items");
}

Its working perfectly to međź‘Ť