Cascade lookup on current logged in user id? #5741
Replies: 1 comment 6 replies
-
There is a solution I posted here #4960 (comment) public static SqlQuery ApplyCurrentUserId(this SqlQuery query)
{
// load userId
var userId = Serenity.Authorization.UserId; // for example
query.Select($"{userId}", "UserId");
return query;
} You can get userId using After you have UserId field in your List/Retrieve query, you can add an Expression field for example : [DisplayName("UserId"), Expression("bl.UserId")]
public String UserId
{
get { return Fields.UserId[this]; }
set { Fields.UserId[this] = value; }
} Finally you can use the userId field for your lookup cascade I have not re-test it for your case but I think it will work, you might need to write more code if you need |
Beta Was this translation helpful? Give feedback.
-
Hello.
I am trying to filter a lookup in a row.cs field using the cascadefield/cascadevalue attribute.
Would there be anyway to retrieve the current logged in user as the 'CascadeValue' attribute within the row.cs file or would the filtering have to be done on the client side?
Any suggestions would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions