Dynamics CRM2013 Reporting: Error Pre-Filtering Report w/ Multiple DataSources
On a recent client I had the task of making one of our already existing Dynamics CRM reports use pre-filtering. This is normally a very straight forward procedure and you can find steps to do this on the following link: https://msdn.microsoft.com/en-us/library/bb955092.aspx.
Now given the complexity of the query used to populate this specific report I needed to use explicit pre-filtering. Once again, this is something that should be fairly straight forward to do. After I finished adjusting the report to use explicit pre-filtering I then deployed my report out to CRM. But when I tried running the report I got the following error: The expected parameter has not been supplied for the report
As we can see from the error it seemed that nothing was getting passed through to my hidden parameter. So the first thing I did was I looked at the report data pane in Visual Studio for my report to make sure the parameter was named correctly. Below is the screenshot:
Everything here seemed to be up to par with what was needed to use explicit pre-filtering: the MSCRM datasource, the hidden parameter with the appropriate naming convention (CRM_FilteredEntity), and the dataset that was getting pre-filtered (OpenWorkOrder).
So needless to say I was very confused as to why CRM wasn’t recognizing my report as one that used pre-filtering. I had tried numerous things, one of which was adding a Default Value to my hidden parameter. All that did was suppress the issue. Instead of getting the error shown above it just returned the report with the given default parameter (hence the data was still not being pre-filtered). So at that point I decided to re-create the report and see where along in the process my issue had occurred. Much to my surprise I was able to re-create the entire report without any issues!! So I compared the report data panes between the original report and my newly created report to see why pre-filtering didn’t work on the original report but did on the newly created one. Below is the screenshot of the newly created report:
So can you see what the issue is? Well I kind of ruined the surprise in my title. It was the two data sources that existed in my report… or, should I say, it was the order of the two data sources. In my new report the MSCRM data source was listed first whereas in the old report the CustomReport data source was listed first. That was it! Apparently, in order for pre-filtering to work in CRM, the MCRM datasource needs to be specified first. If it is not then CRM will not recognize the report as one that is using pre-filtering and you will run into the issue that I encountered above.