Ticket T214693
Visible to All Users

How to create @CurrentUser parameter, instead of @CurrentUserId

created 10 years ago

Hi.

I have certain listviews that I would like to filter based upon fields that exist for the current user. I am using the security system, with custom SecuritySystemUser types. These types are derivatives of yours, so not significantly different.

Let's say my CustomSecuritySystemUser has a Person reference, and I want their date of birth, in order to filter a list of birth certificates.
In the user model I would like to set the Filter setting, for the view to something like this:

DateOfBirth = @CurrentUser.Person.DateOfBirth

Currently all I have is CurrentUserId and I'm not sure how to reference that in the CriteriaOperator… but it seems the best way to go would be to create a custom @CurrentUser function that maps to this.

Could you offer some guidance please?

Thank you.

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hello Denis,

Read-only parameter is an outdated technique, and we recommend that you use other ways to get the current user's properties. For example, you can use a Free Join query: "[<SecuritySystemUser>][Oid = CurrentUserId() and Person.DateOfBirth = ^.DateOfBirth]". Another way is to implement a custom function that will get the current user using the SecuritySystem.CurrentUser property and return the value of the required property: "DateOfBirth = CurrentPersonDateOfBirth()".
Feel free to contact us in case of any difficulty.

    Comments (2)

      Perfect thank you Anatol! I wasn't aware of the Free Join functionality. :(

      Anatol (DevExpress) 10 years ago

        You are welcome!

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.