ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Getting child table size (number of rows)

Hello;
How can I know the number of rows that the child table is containing?
If they are 5 or 6 or 10 rows?
Regards
Bilal

1 Like

In python:

len(self.get("table_fieldname"))

In javascript:
frm.doc.table-fieldname.length

6 Likes

Thanks a lot for your kindly reply.

It is meant by the table is the tablename?
So if the table name is items then it will be as following (please advise):

In python:

len(self.get(“items_fieldname”))

In javascript:

frm.doc.items-fieldname.length

Appreciate the kindly advise.

Regards
Bilal

For Sales Order Item table, it will be len(self.get(“items”)) and frm.doc.items.length

2 Likes

Very helpful sir

I tried to use

frm.doc.items.length

But I get Error

purchase_order__custom_js:3 Uncaught (in promise) ReferenceError: frm is not defined

My problem is that when I use

cur_frm.get_field(“items”).grid.grid_rows.length

I get the correct length.
but if the items table is more than 50, the form is paginated and I get errors

The solution is to use the $.each()function as described here: