Checking whether the currently logged user belongs to a certain role in a filter becomes easier in 11.1.7

XAF Team Blog
12 September 2011


I am confident that every user who utilized XAF’s Security module with the Complex Security strategy should have met this requirement at least once using XAF, for example, when you had to filter out a ListView to display records only for people from the Administrators role and hide them from the rest. Or, you wanted to make your favorite Appearance or Validation rule work only for people from the Users role? Sound familiar?

A good way to address such requirements is to implement a custom function criteria operator. Tolis recently demonstrated how it can be done in his recent blog post about applying security to the State Machine module. The first time I saw the blog, I thought that it would be nice to have such a function in XAF out-of-the-box. So, shortly thereafter, after seeing a discussion on the forum, I logged a corresponding feature request.

New built-in criteria function

This feature request was implemented in version 11.1.7, and that means that you can already make use of the new IsCurrentUserInRole function in your criteria. The function’s use is very simple. All that you need to do is to pass the name of the role as a parameter:


I expect that this built-in criteria function will be no less popular than the CurrentUserId()  function and will also save you a lot of time, because the described requirements are quite common in business applications.

Future plans

While we are talking about custom criteria functions, a note about our future plans. Although XAF already provides a similar feature called Read-Only Parameters, we are gradually stepping away from it and moving towards custom criteria functions everywhere. This is because they provide more capabilities (e.g. they are supported by all DevExpress products and not only in XAF; functions can accept arguments whereas Read Only Parameters are constants, etc.). It is intended not only to optimize our support costs, but also to allow a faster evolution of our products.

Do you like this small improvement? Please let us know your opinion! Happy XAFing!Winking smile

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.