logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Sekharg  
#1 Posted : Tuesday, February 15, 2022 10:25:02 AM(UTC)
Sekharg

Rank: Member

Groups: Registered
Joined: 2/19/2021(UTC)
Posts: 10
India

Thanks: 2 times
Hey Eric,

How to filter Enum List with Logged In UserId?

Thanks,
Sekhar G
epf  
#2 Posted : Tuesday, February 15, 2022 6:10:51 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
To do that, you have to write some C# to refresh your enum list in the 'Report Execution Init Script'

The script may look like:
Code:
@{
    Report report = Model;
	ReportExecutionLog log = report;

    if (report.SecurityContext != null) {
        var myEnum = report.Sources.First(i => i.Name=="A source name").MetaData.Enums.First(i => i.Name == "A enum name");
        myEnum.Values.Clear();
        if (report.SecurityContext.Name == "A name" || report.SecurityContext.BelongsToGroup("aGroup")) {
            myEnum.Values.Add(new MetaEV() {Id="1", Val = "1 Val"});
            myEnum.Values.Add(new MetaEV() {Id="2", Val = "2 Val"});
        }
    }
}

Edited by user Tuesday, February 15, 2022 6:11:57 PM(UTC)  | Reason: Not specified

Sekharg  
#3 Posted : Wednesday, February 16, 2022 5:23:33 AM(UTC)
Sekharg

Rank: Member

Groups: Registered
Joined: 2/19/2021(UTC)
Posts: 10
India

Thanks: 2 times
For Enum i need to pass this param as like this,

so please advice

select id,name from vw_Sales where UserId= <LoggedinUserId>

epf  
#4 Posted : Thursday, February 17, 2022 8:00:15 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
You can do that like this:

Code:
        //Or change the SQL
        anEnum.Sql = $"select id, name from aTable where aColumn = {Helper.QuoteSingle(report.SecurityContext.Name)}";
        anEnum.RefreshEnum();

Edited by user Thursday, February 17, 2022 8:00:49 AM(UTC)  | Reason: Not specified

Sekharg  
#5 Posted : Saturday, January 21, 2023 2:07:59 PM(UTC)
Sekharg

Rank: Member

Groups: Registered
Joined: 2/19/2021(UTC)
Posts: 10
India

Thanks: 2 times
How can i add one more parameter for SecurityContext -> UserId


i want to give role based access for all reports as common parameter ? with UserId in Enums

Edited by user Saturday, January 21, 2023 3:00:42 PM(UTC)  | Reason: Not specified

Users browsing this topic
Guest (2)
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.