Rank: Newbie
Groups: Registered
Joined: 9/8/2016(UTC) Posts: 8 Location: Caxias do sul Thanks: 2 times
|
Hi!
I need to filter my enumerated lists based on the current user, is there a way to use Environment.UserName with the SQL query?
Thanks!
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
Good question, here is how to do it with the 3.0: Select your root view and edit the 'Init Script' where you can modify your report definition before it is being rendering... Code: var source = report.Sources.FirstOrDefault(i => i.Name == "Northwind (Repository)");
if (source != null) {
var enumList = source.MetaData.Enums.FirstOrDefault(i => i.Name == "Last Name");
if (enumList != null) {
report.LogMessage("Refreshing Enum values...");
var userName = report.SecurityContext != null ? report.SecurityContext.Name : "No context";
enumList.Sql = string.Format("select LastName, '{0}-' + LastName from employees", userName);
enumList.RefreshEnum();
}
}
This code select an enum list from a source, then it updates its Sql Statement and finally refresh the values... The SecurityContext allows you to get the login name got from the Web Report Server, you can of course change the SQL with a where clause having Environment.UserName. In 3.1, you will be able to add this code directly in the Enum definition, so it can defined in the repository source and applied to all reports...
|
1 user thanked epf for this useful post.
|
|
|
Rank: Newbie
Groups: Registered
Joined: 9/8/2016(UTC) Posts: 8 Location: Caxias do sul Thanks: 2 times
|
Thank you epf, it worked!
Good to know about 3.1.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.