Child table add initial row

When we add a new BOM, we can see the Items grid has already a new row added

I’d like to do the same for my custom doctype, but I can’t find how it is done in bom.js.

Any idea how to do this ?

Ah found it, it seems to be the behavior because the table field is set as Mandatory.

And an alternative is to call this in the form refresh event

if (frm.is_new()) {
   if (!frm.doc.items || frm.doc.items.length==0) {

Thanks lot