Hi Umme,
The issue is primarily related to how Mendix handles the current user and the correct usage of associations in OQL and XPath.
OQL – @CurrentUser is not supported
In Mendix OQL, @CurrentUser cannot be used directly in the WHERE clause. OQL only supports parameters, which must be passed to the query through the data source configuration. Using @CurrentUser directly will therefore result in an error.
Correct approach in OQL
Instead, you should define an OQL parameter and pass the current user as an object parameter to the query. This can be done using the Java action provided by OQL to add an object parameter, and then reference that parameter in the WHERE clause.
This approach is the supported and recommended way to use parameters in OQL.
you can also find the example usage of this action under the Examples in the OQL Module
Example Scenario:
In Mendix OQL, @ cannot be used for parameters because OQL does not support SQL-style variable notation; instead, it only supports named parameters defined with $. Parameters must be written as $ParameterName. This is why WHERE U.id = @CurrentUser causes an error, while WHERE U.id = $CurrentUser is the correct and supported approach in Mendix OQL. Before the execution activity, please use "Add object parameter" activity like below: