Last week I was working on a “Customer Statement” Report in Microsoft Dynamics NAV 2017 database. This report was a copy of the original “Statement” (Report 116). Once the modification was done, I simply change the report selection in the Database and then ran the report using Development Environment.
Applied few filters to the report and it gave the output as I expected. Works perfectly fine!
After couple of hours, one of my colleague came and inform me that report is not working as expected. His complain was report does not filter the dataset according to the filters set at the request page.
Since the RTC was already open I just thought to run the report to check. I typed the report name and just add a customer filter and click Ok.
I got totally unexpected result as the output. Report just ran without applying any filters to the dataset. I opened up my development environment and then ran the report from there and then add few filters and click ok.
Sweet! Report produced the exactly expected output. So what is the misery in here. Change the report selection and put the 116 as the report number (default report) and then ran the report using RTC. It works perfectly fine.
I design the MenuSuite of the Dynamics NAV 2017 and found that report is called using a codeunit. May be you have seen already, in Microsoft Dynamics NAV MenuSuite, there are some codeunits attached.
In this scenario, codeunit “Customer Layout – Statement” (8810) handle the report calling.
“Documentation( )// Wrapper codeunit to call 8800 – allows menus and objects to invoke a CU directly to get the per-customer// layout support for statements.“
If you went through the code you will see, Report Request page is saved as a XML and then pass it to Codeunit “Request Page Parameters Helper” (1530) to evaluate the filters.
This is how my report’s request page looks like
This is how the “RUNREQUESTPAGE” return XML look’s like.
In the codeunit “Request Page Parameters Helper” (1530), it loop through each XML node and compare it with the Dataset “Table Caption” or “Table Name”.
This is where my new report get into trouble. To confirm my guess I put a message box and execute the report again.
It result the following message box :
Left side of the equation return the “Document Header” and right side of the equation always return the “Customer“. Condition get failed every time and it never go in and SETVIEW. Which result report running without any filters applied.
From where the “Document Header” come from?
It is the Name of my Report Dataset (Customer). Default it comes as the “Customer”, but we wanted to make it more generic, so we change it to “Document Header”.
If we have several dataitems with same table ID in a report, then report will never going to work with the current logic build in the “Request Page Parameters Helper” codeunit.
Please provide your feedback with a comment.
Thank you and Regards,