When a DocType’s title_field is set to an invalid fieldname (e.g., "name" which is a system field), the List View throws a console JavaScript error and renders zero records instead of displaying a user-friendly error or falling back gracefully.
This is confusing because:
-
Records exist in the database.
-
No error message is shown to the user.
-
The DocType form also fails to save with “Title field must be a valid fieldname” but this message only shows up when trying to edit the DocType.
Likely Cause:
ListView.get_header_html() looks up title_field in the fields array. When the field doesn’t exist, it returns undefined, then crashes trying to access fieldname.
Steps to Reproduce:
-
Create a DocType with some records
-
In the DocType JSON, set “title_field”: “name” (or any non-existent fieldname)
-
Navigate to /app/{doctype-name}
-
Observe: Empty list, error in console
Console Error:
list_view.js:696 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'fieldname')
at ListView.get_header_html (list_view.js:696:59)
at ListView.render_header (list_view.js:603:30)
at ListView.setup_view (list_view.js:327:8)
Expected Behavior:
-
Validate
title_fieldon save, or -
Fall back gracefully if field doesn’t exist, or
-
Show user-facing error message
Workaround:
I set "title_field": "" and I was able to then see the records in the DocType
Frappe Version: v15.93.0