Not able to fetch child table in frappe.get_list

I’m trying to fetch a doctype using frappe.get_list, it contains an (“indent_point”) child column.
Not able to access child table .

indents = frappe.db.get_list(“Indent”, fields = [“indent_point”])
error: pymysql.err.OperationalError: (1054, “Unknown column ‘indent_point’ in ‘field list’”)

Child tables are not directly available in get_list as it is not ideal for performance.

you can either improve the design on your end or choose to map it yourself.

indent_list = frappe.db.get_list('Indent')

for doc in indent_list:
    doc["indent_point"] = frappe.get_doc("Indent", doc.name).get("indent_point")

return indent_list

2 Likes

Hi @nithishwar_s,

Please check syntax.

# Fetch the Parent Document and Access Child Table Data
indent = frappe.get_doc("Indent", "Your_Indent_Name")
child_table_data = indent.get("indent_point")

# OR

# Fetch Child Table Data Directly
child_table_data = frappe.db.get_all("Indent Point", filters={"parent": "Your_Indent_Name"}, fields=["*"])

Please check the concept for check the documentation.

Thank You!

3 Likes