In ERPNext v15, how can I set a filter for a date?
For example:
- From Date: 18/01/2025 (10 days before today)
- To Date: 28/01/2025 (Today)
I want to set this in the filter fields of report.
In ERPNext v15, how can I set a filter for a date?
For example:
I want to set this in the filter fields of report.
If your report is Script or Query Report, check this
frappe.query_reports["Report Name"] = {
filters: [
{
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
width: "40",
default: frappe.datetime.get_today(),// Here you can set the default value of the date field
reqd: 1,
},
{
fieldname: "to_date",
label: __("To Date"),
fieldtype: "Date",
width: "40",
default: frappe.datetime.get_today(),// Here you can set the default value of the date field
reqd: 1,
},
],
};
I
For example, if today is January 31, 2025, then:
From date: January 21, 2025 (10 days before today)
To date: January 31, 2025 (today’s date)
frappe.query_reports["Your Report Name"] = {
"filters": [
{
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.datetime.add_days(frappe.datetime.get_today(), -10),
"reqd": 1
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.datetime.get_today(),
"reqd": 1
}
]
};
plz check this @jankijoshi
I have tried this but is not working, even I tried in script section, as you said but still it is not working @Vipul_Kumar
You have to write this code in the js file of this Early Going Employee Report. In your code editor add this code. Is it a custom Script report?
It is a Query Report and can’t we add those filters directly in the default field of filter table.