Accessing checkbox in filters for queryreport

Hi

I have written a custom query report ( client side). Thats working fine.

I have added a few filters which are also working fine.

I now want to add a checkbox. It works when the checkbox is ticked.
When I untick the checkbox I get an error :KeyError: ‘nr’

It seems I am not accessing the checkbox info in a way that is updated correctly.

I have tried various ways …

%(nr)s

filters.get(“nr”) ( this yields another error that suggests that I am not allowed
to use this method )

report_filters.get(“nr”) ( same as the one just above )

I also tried defining my filters, not in the “filters” section of the report but in the script section of the query report…

frappe.query_reports[‘Test’] = {
“filters”: [
{
fieldname: “nr”,
label: “Nr”,
fieldtype: “Check”
},
// … other filters
]
}
With this last method, when i run the browser in debugger mode, I see the link to the
report but filters is empty … filters

PLease help

Please check it.

Thank you @NCP for you rmessage.

In my post you will see that I did try the suggestion from the post

Adding Filters in Query Report - #4 by NCP

It seems that with the

%(checkbox)s

method, the content of the checkbox is not read properly when the checkbox
is not set. That is why I tried the suggestion listed in the post that you mentioned.

@gsarunk , made s suggestion in the post

V13-How to default the filter value in Query reports

and I tried that but it did not work. Not sure if I did it incorrectly. I loaded my
definition into the “script” part of my custom query report. Here is a copy from my
first post …

frappe.query_reports[‘Test’] = {
“filters”: [
{
fieldname: “nr”,
label: “Nr”,
fieldtype: “Check”
},
// … other filters
]
}

but when I used my browser in debugger mode, I saw the link to my report but the
filter definition “filter” was empty. This seem to suggest that it did not pick up my
filter definition that I made in the “script” part of my report.

I also tried this way of reading the state of the checkbox …

filters.get(“nr”)

But I got an error that stated that I was not allow that method.

So I am still stuck.

Could you please share the screenshot of filter section, Query/Script section and Client code js section of the custom report you have created

Thank you for the response @gsarunk

I could work around the problem by using a “Select” instead of a “Check”. Then
I would simply use “Yes” and “No” as my options and change the code accordingly.
Then my code works.

But I would like to understand what I am doing wrong in the case of using a
“Check” box

Here is a screenshot of my code. Please note that the filers section are set in the
screenshot. I added them afterwards just to get the code running but I actually
did my initial testing with only the filters-setting as in the “script” section.

Thank you

From looking into your configuration, everything looks fine.
I don’t understand the reason why you have made checkbox as mandatory. Checkbox can never be mandatory.

Also were you able to get the select woking without passing the checkbox and only your user filter?