Hello Frappe Community,
I’ve been attempting to create a Script Report in ERPNext to display some basic metrics (e.g., attendance details, salary info, etc.). I received a detailed solution from an AI assistant (see code snippet below), but my script still isn’t working—it always shows “Nothing to show” or yields no data. Here’s a summary of what I’ve tried:
- Used the AI-generated script: I pasted it exactly in the “Query/Script” box for a new Script Report (Report Type = “Script Report,” “Disable Prepared Report” checked).
- Verified Data & Permissions:
- Linked my user to an Employee record.
- Gave “Read” permission on relevant doctypes (Employee, Attendance, etc.).
- Added or tested sample data in “Attendance” or “Employee Checkin” (in case the script needs real records).
- Rebuilt Assets (if self‐hosted) and reloaded the page.
- Embedded the report in my “Employee Dashboard” workspace.
Despite all this, the report still shows no rows or “Nothing to show.” I’ve combed through the AI’s troubleshooting steps (like checking for a forced row of data, verifying code syntax, etc.), but I’m stuck.
AI-Generated Script Snippet (Sample)
python
Copy
def execute(filters=None):
columns = [
{"fieldname": "invalid_count", "label": "Invalid Punches", "fieldtype": "Int"},
{"fieldname": "late_count", "label": "Late Marks", "fieldtype": "Int"},
{"fieldname": "unpunched", "label": "Unpunched Days", "fieldtype": "Int"},
{"fieldname": "today_checkins", "label": "Today's Checkins", "fieldtype": "Int"}
]
user = frappe.session.user
employee = frappe.db.get_value("Employee", {"user_id": user}, "name")
if not employee:
frappe.msgprint("No Employee Found for user: {}".format(user))
data = [{"invalid_count": 0, "late_count": 0, "unpunched": 0, "today_checkins": 0}]
return columns, data
# Some date logic (last 30 days, etc.)
# Some counts on Attendance or Employee Checkin
# Return a single row with the counts
data = [{"invalid_count": 2, "late_count": 1, "unpunched": 3, "today_checkins": 0}]
return columns, data