ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

How to validate the checkbox in child table consists of 10 Rows

customization

#1

I have an child table in my doctype its consists of 10 rows i need to validate every row that the checkbox is enabled r not if its not i wont allow to submit …

here is my code it oly viewing the single row not all! can u guys help me to sort out this problem…

for i in self.get("items"):
    if i.label_printed == 0:
        frappe.throw('Err")

#2

Never compare it to zero unless you have explicitly set the default value of the checkmark to zero. Use this instead:

if not i.label_printed

Also, one more:

Wrong quotes usage. You started with a single quote and ended with a double quote.


#3

still it was validating a single row…i need to validate for all rowsss


#4

If this condition is required for ALL cases (All item codes all situations) then, simply keep it mandatory no need for this code.


Then try like this:

invalid_rows = []

for i in self.get("items"):
    if not i.label_printed:
        invalid_rows.append(str(i.idx))

#after loop ends
if invalid_rows:
    row_string = ','.join(invalid_rows)
    frappe.throw("Label Printed not checked in rows {0}".format(row_string))

#5

Thanks alot @root13F this codes fixed my issues…