ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

V13-How to default the filter value in Query reports

All,
I am trying to build a custom query report in V13. Query report now allows us to define the filters. However I am not able to default the value of filters.
For eg I want to default the value of date_from and date_to to month start and month end.


There is no option to give the default values.

There is a script section in the query report. Could someone show how to use this feature. For example how to manipulate the result from the query

1 Like

I have the analysed the frappe framework on how the reports are being executed. https://github.com/frappe/frappe/blob/develop/frappe/desk/query_report.py.
the code executes query in the query section with filter if it is a query report else runs with the script in the script section.
So when you choose the option as script report client script section will open.

Here is a little hack. Maybe this is a bug. For now i am using this bug to my favour.
You can define the filter here with default values in the client script section like below


save the report. Run the report once to get the filter value

now switch back the report type to query report.
now use the filters as usual. Note please don’t define the filters in the filter section.