I want to hide some fields in the report depending on a few options set in Request Page. To achieve that I follow this steps:
1.- Create a global variable to sotre the field of the request page.
2.- Add a field to the request page and set the SourceExpr to the variable created on step 1.
3.- Add an invisible field on report sections with the SourceExpr to the same variable and set a DataSetName.
4.- Go to the Report Layout, and use the field in the dataset to change visibility on a field.
When i try to execute the report and set de checkbox in the requestpage, it’s throwing an error because the variable is null.
So i check for the datatype of the dataset field in the report and is correct, it set as a boolean. I made a few more test, checking the value of the bool trying printing them without success.
The i think that the problem maybe related with checkboxes and booleans so I follow the same 4 steps but this time with a text variable and a textbox. Th report is still printing nothing. Like the value of the dataset field was empty.
When I check the same but running with classic client i see that it’s printig right! I don’t know where is my mistake, i’m pretty sure that i made something wrong but i can’t figure it out.
Anybody can help me with this? Thank you very much.
Here is the exact error message (In Spanish and English):
SPANISH: “No se pudo representar el resultado del informe; Se produjo el siguiente error: La expresión Hidden utilizada en el objeto ‘txtTest’ de tipo textbox ha devuelto un tipo de datos que no es válido.”
ENGLISH: “Could not render the result of the report, the following error occurred: The Hidden expression used in object ‘txtTest’ of type textbox returned a data type that is not valid.”
And here is the hidden expression:
=Not(Fields!boolTest.Value)
Where “boolTest” is the dataset name of the variable.
When i received this error for first time, I try to print the “boolTest” value using this expressións:
IIf(Fields!boolTest.Value,“TRUE”,“FALSE”)
"boolTest = " + Fields!boolTest.Value;
"boolTest = " + CStr(Fields!boolTest.Value);
The first expressión print “FALSE” when established true or false to the checkbox. and the next two sentences print empty.
After that, i made the same with a new variable, of type text, and the result was the same, it print empty.
When i made this expressions in the classic report (via sections menu) everything is working, in the classic report the test texboxes print the correct values for the boolean and the text.
So, like i said before i’m guessing that the expressión in the report isn’t the problem, the problem is the value getting by the report, it’s get empty or null or something like that instead of the actual value of the request page, but i don’t know why.
Have you checked if the XML dataset file generated by NAV actually holds the content of your variable? Either check the exact file, or use the Help > About this Report from the report preview.
Hi, I debug the code and i see the variable and the value is correct. I check for the boolean variable and the testText variable to check the values in debug and the value is correct.
The boolean has true when i checked in the request page and de text has “Text” as value like i write in the request page.
I notice that the datasetfieldname is diferent that the name of the variable in the C# so i change the name to match with the C# code but with no results.
So, the value in the C# is set, but the report still getting nothing. Any ideas?
Always is a pleasuer to speak to spanish coleagues.
First of all, you can’t concatenate “decimal” or “boolean” values directly to text because of it causes error:
"boolTest = " + Fields!boolTest.Value;
"boolTest = " + CStr(Fields!boolTest.Value);
That’s the error that it’s showing you. You have to use debugger to watch your variable values. That kind of “watch” is very rudimentary (even though I think we all have done it some times
To concatenate you have to use de Formatted version of the variable (usually is “name of variable”_Format)
And now, focusing in your problem, you have to be sure that the variable BoolTest is defined in the corresponding Dataitem because if you define the variable in another Dataitem, the Dataset_Result knows that there are a variablecalled BollTest but the Tablix doesn’t know which values have it.
Thanks to correct me, you were right, i was using this to watch variables i will use debugger from now. But i don’t know if it’s completly correct, because Debugging the value is set, but printing (in case of NavText type) is not.
Anyway, lesson learn, thank you!
I’m not sure i can do that, because the variable is not a table column, it’s a global variable, when i tried to add inthe report designer it says to me that “The variable ‘boolTest’ it’s defined more than once”.
I should addit to dataitem but remove it from global variable?
Don’t worry, i don’t think you didn’t explain well, the problem is only on my lack of knowledge!
I tried what you suggest but something i’m doing wrong.
First, i create for testing pourpose a global var named “txtTest”.
Second, i addit in the Request Page a textbox pointing to that var via SourceExpr.
Then I try to addit as DataItem in the Report Designer. The interface is not like the one you show me. I had the columns DataItem and Name but not DataSource, i guess it is because the navision client version… anyway, when i tried to add it via integer table, i get an error message:
SPANISH: “La variable ‘TXTTEST’ está definida más de una vez. Este error se produce, por ejemplo, si se define una variable de nombre ‘File’, ya que ‘File’ es al mismo tiempo un tipo de datos.”
ENGLISH: “The variable ‘TXTTEST’ is defined more than once. This error occurs, for example, if you define a variable named ‘File’, since ‘File’ is both a data type.”
I’m pretty sure that what you tell me to add is in another place, and not de Report Designer. Anyway i can’t believe how many problems and “tricky” workarounds are to get a value from a Request Page in a RDLC Report. The “process” to do the same in the Classic reports is so much simple and without errors!.
It worked! I put in the Sales Shipment Line because this is the place where i want to use it, I don’t even imagine that the section where i put the textbox play any rol on this. Now I know! Thank You!
But i have a question, in orden to improve my learning, Why the Body section is an incorrect section to do this?
P.D. I don’t have a list in body section i display the Sales Shipment Line in a table, but I think is pretty similar, i don’t really know my knowledge is reduced to classic reports.
This is more or less what I was trying to explain you before.
You have to put the var into the right Dataitem (in NAV 2013), in NAV 2009 you have to put the var (added as an invisible text box) into the right Section.