This is a migrated thread and some comments may be shown as answers.

Passing a value from the report viewer to the report

3 Answers 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
pierre-jean
Top achievements
Rank 1
Veteran
Iron
pierre-jean asked on 23 Jan 2021, 02:33 PM

Hello

I would like to pass a value from the report viewer to the report (ex: my application user's name)

I can do this by adding a parameter but in this case I must add the parameter in the data retrieval method while I do not need it in this contex; and since I have a number of such values to be passed it is not a very practical solution.

Is there another mechanisms ?

From what I have read it seems possible to use the useridentity, but  have not found how to use it ...

or there may be another (simple) mechanism ...

3 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 27 Jan 2021, 02:33 PM

Hello Pierre-Jean,

Indeed, the UserIdentity Global Object represents by default the current user. For example, for the web applications, it gets populated by the virtual GetUserIdentity method of the ReportsController. The default UserIdentity retrieval logic sets it to System.Web.HttpContext.Current.User.Identity. You may override the virtual method if you need a different user to be represented in the report.

Note that with the UserIdentity.Context property you may pass also other objects directly to your reports - see the KB article How to Use UserIdentity.Context to Pass Custom Objects to the Report.

Regards,
Todor
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 06 Feb 2021, 03:18 PM

Thanks a lot for your reply

Actually I found a simpler and probably more straight forward way to achieve this.

I just added a parameter to the report; the thing I miss-understood initially is that this new parameter does not need to be added to the object datasource and thus is not passed to the associated dataprocessing function

Thanks again

Best Regards

Pierre-Jean

0
Todor
Telerik team
answered on 10 Feb 2021, 09:57 AM

Hello Pierre-Jean,

Indeed, you may use Report Parameters for general purposes in the report and not link them to any data source parameters. I confirm that this is the most straight-forward approach for passing a value from the viewer to the report.

Regards,
Todor
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Answers by
Todor
Telerik team
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Share this question
or