Function Criteria Operators
- 4 minutes to read
The XAF includes various techniques to filter List Views: at the data source level, in the Application Model, and with special methods for filtering Lookup Property Editor List Views. In each technique, you may need to set static variables as filter criteria values. For example, the filter “Task.DueDate must be set to the current date” needs the CurrentDate variable (calculated each time it is required). For this purpose, use Function Criteria Operators, which represent functions that return a specific value (such as the current date or the current user) or the result of handling the specified arguments (such as the concatenation function). This topic describes Function Criteria Operators, shows how to use them when filtering, and explains how to implement Custom Function Operators.
#Function Criteria Operators Basics
Function Criteria Operators are a part of the criteria language. In criteria strings, a Function Criteria Operator name should be followed by brackets containing operands that represent function arguments, or empty brackets if it does not take arguments. The following criterion demonstrates how to use the LocalDateTimeToday Operator:
[Task.DueDate] = LocalDateTimeToday()
Multiple Function Criteria Operators, such as LocalDateTimeAfterTomorrow or Replace, are available out of the box. Refer to the FunctionOperatorType help topic for a complete list. The following table lists the XAF-specific Function Criteria Operators available in XAF applications:
Operator | Description | Examples |
---|---|---|
Current | Returns the current user’s identifier. This custom Function Criteria Operator is registered in the System |
|
Current | Returns the current tenant‘s identifier. This custom Function Criteria Operator is registered in the System |
|
Is | Returns True if the current user has the specified identifier. This custom Function Criteria Operator is registered in the System |
|
IsCurrentUserInRole(roleName) | Determines whether the currently logged on user is assigned to a specified role. Returns false when no user is currently logged on. The Security |
|
Is | Indicates whether a specified object has been created but not saved to the database. This operator gets the current Object Space using the static Base |
|
#Important Remark on the DateTime Function Criteria Operators
The DateTime parameters do not support addition and subtraction operations. The following expression is incorrect:
[Task.DueDate] > (LocalDateTimeToday() - 3) AND [Task.DueDate] < (LocalDateTimeToday() + 3)
To add or subtract values from the DateTime parameters, use the DateTime management functions the XPO exposes, such as AddDays and AddYears. For instance, this is the correct way to write the previous criterion:
[Task.DueDate] > ADDDAYS(LocalDateTimeToday(), -3) AND [Task.DueDate] < ADDDAYS(LocalDateTimeToday(), 3)
For a complete list of functions with descriptions, refer to the Criteria Language Syntax help topic.
Note
Date