RDLC Report cannot get value from Request Page

Hi!

I’m having an issue that is driving crazy.

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.

Can you show us the exact error message which you are getting?

Can you show us the Hidden expression set on text boxes?

Hi Mohana,

Sorry by the late response.

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.

I check the results of Help > About this Report and i can see the variable, but the value of that variable is “<>” wich i guess mean null or empty.

Yes, then it means that your variable has not been initiated. But try to debug the report to see if the variable is being set or not.

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?

Thank you for your effort!

Hi Carlos,

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 :slight_smile:

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.

Some images to clarify it:

http://oi43.tinypic.com/6o33i8.jpg

http://oi39.tinypic.com/2hcn815.jpg

I hope it helps.

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?

Sorry for the quick post of this morning, I was quite busy at the office and I couldn’t explain as well as I would like to.

First of all, you have to define your global var as always:

Name DataType Subtype Length
boolTest Boolean

Then, you add your global var to the DataItem that is used in your Tablix.

http://oi43.tinypic.com/6o33i8.jpg

If you have added the variable in the right Dataitem, you now can use it in the Layout.

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!.

I guess you are using NAV2009…

You need to add the boolean in proper section by visible false to pass it to visual studio dataset.

then you can use it in visual studio expressions

That’s right Mohana, i post in the worng subforum? If my doubt is about NAV2009 i should post in another place? Sorry about that :confused:

What you suggest is just what i did in first place, but without success!

Let me explain it again. For testing and explaining pourposes i’m going to talk about a text variable.

1.- I create a text variable named “txtTest”

2.- Add a textbox field in Request Page called “textBoxTest” with a SourceExpr pointing to “txtTest”

3.- Add a textbox in ReportSections on the section when i want to print the value of the variable. Set de DataSetFieldName to a “txtTest”

4.- Open layout and add a textbox with a value expresion like this: “=Fields!txtTest.Value”.

Whe i print the report, the textbox is empty. But debugging, in the C# Code the variable has the correcta value passing by Request Page.

Any ideas?

No, you posted in right place only but always mention which version are you using in your question [:)]

Strange. There must be something wrong.

Can you upload your report object here in txt format?

or show us the screenshots where and how you have added.

You’re right, Thanks Mohana, I’ll keep in mind in the future!

So, i repeat the entire process with a test variable named “txtTest” to make screenshots in a “clean way”.

Report Designer:

Add Global Variable:

Add Request Page Field:

Add an invisible textbox in sections designer:

With this properties:

Add to layout:

Set value in Request Page from RTC:

8032.SetValueRequestPage.png

Print report:

If I made the same steps but using Request form and execute classic report instead, the “txtTest” value is printed right.

I’m very new to Navision developing, so i’m pretty sure that i made something wrong, i just don’t know what!

Once again, thanks for your effort!

Can you try by moving the invisible text box from Sales Shipment Line, Body section to PageLoop, Header Section?

I guess you didnt have any list in body section of your rdlc report?

Hi Mohana!

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.

Anyway, problem solved!

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.

I think i missunderstood before… Now in case we move to NAV2013 I know what is the procedure to achieve that, Thanks!