+1 800 256 3608 (toll-free in North America) or +49 7531 9060-10| service@combit.com

User variable repeated for all pages

Hi,
I need to use a “User variable” in the header of the report, so to be repeated for all pages.
I have used a tex box like “Name:” and a user variable like “@userName” with the value of the user name.
This variable is taken from a table available in the datasource of the report, that contains many fields including the user name.
In Layout Preview I saw something like “Name: Mickey Mouse”, then I assigned both text for all the layers, but in the Preview I just see “Name:” and the variable content is empty.
What I’m missing?

Thanks

I noticed that if I add a Report Parameters with the value included in the same table as the User Variable, I can see the “@userName” correctly in all pages in Preview.

Hi Ivano,
if you assign a value from the table to the user variable, you must ensure that the text object used is printed after the table or report container.
See image:

If you don’t use databinding you would have to link (Sequential) the text object with the table.

Hi Erdal,
I’ve tried in this way but it doesn’t work. I cannot see the @userName in the Preview (just in the Layout Preview)

Could you please answer the following questions, thank you.

  • Do you have the real data preview in the designer?
  • Which development environment do you use to develop it?
  • Is it visible when you print it correctly?

Maybe it helps that you upload the used project file.

I found the issue: since I have a lot of table from datasource I was not using the table with the user variable.
Inserting this table with empty lines (so is not visible), I’m able to correctly visualize the user variable.
Thanks

1 Like

I have another question regarding this topic:
In the table I have many users, and in the @userName variable I would like to insert some condition to visualize it.
For example if I have a field, in the Users table, that contains the city of the user, and I have a variable (passed from the C# code) tha is called “myCity”. I would like to view the @userVariable value when the following condition is true:
Users.City == myCity
Example:
DB Table “User” contains
immagine

“myCity” = Oxford

so I want to get the name “John” as value in the @userName

It is possible?

You could use the variable “myCity” for the table “User” in the filter, then the table would show only this record and the @userVariable would contain the needed value.
e.g.
User.City==myCity

Whether this is optimal for the performance, would change depending on the datasource (number of records etc.), it would be optimal of course if you could define the filter already in your application.

Another possibility would be to work with SetVar() and GetVar().
Workflow:
Add the content SetVar(“userVariable”, User.Name, false) in the required column.
Use the following display condition:
User.City==myCity

At the required position, read the value of the variable using GetVar(“userVariable”).

© combit GmbH