I am working on a reporting framework with will provide Crystal Reports with data in the form of a DataTable rather than using SQL or any other connection as a DataSource and will display the report in the WPF CrystalReportViewer. It works great, if I have DataRows...However if there is no data being provided, I get overwhelmed with "Field is not known" exceptions.
Below is a quick explanation on how the report is displayed:
Like I said, everything works if there are records, but if there is not, I get a lot of "Field is not known exceptions". Due to the requirements of this framework, I cannot define a type that the records will be as it needs to be left open for extensibility. End Users may customize the OData results to provide additional fields.
My first question is:
If there is no data being provided, why does Crystal even try to parse the "Detail" bands?
To get around this issue, I am passing in a parameter called "IsEmpty" = true if there is no data in the DataTable. Then, I use formulas to display my data.
i.e.-
if({?IsEmpty}) then "" else {Command.Item}
This leads me to my second question:
If the expression is true, why is the false condition being evaluated? I still get that the "Field is not known" for the "Item" field.
Is there a way to NOT evaluate the "Detail" band or formulas if there is no data?