name = $c:account/c:attributes/ri:uid
Using Expressions in midPoint Query Language
MidPoint Query Language (MQL) provides a special syntax support for most common expression types.
To ensure security, expressions are not executed in search boxes in midPoint GUI as that would enable users to execute code. |
Script expressions are supported for the following filters:
-
-
=
,<
,>
,<=
,>=
-
equal
,less
,greater
,lessOrEqual
,greaterOrEqual
-
-
-
contains
,startsWith
,endsWith
-
Path Expressions
The syntax for path expressions is straight-forward since most path expressions reference variables.
Variables start with the dollar $
symbol and they are only supported as right-hand side values.
Scripts
There are two syntax options for script expressions:
-
single-line scripts
-
multi-line scripts
By default, scripts are Groovy scripts, unless other scripting language is specified.
metadata/createTimestamp > `basic.fromNow("-P30D")`
Single-line expressions are written as strings surrounded by single backtick (`
) characters.
This enables you to use quotes inside scripts without needing to escape them.
metadata/createTimestamp > ``` now = basic.currentDateTime(); ret = basic.addDuration(now, "-P30D"); return ret ```
The syntax for multi-line expressions starts with triple backticks followed by a new-line (```\n
).
The script body is enclosed by triple backticks (```
).
This minimizes the need for escaping most of the quotes or sequences inside the script body.
Other Scripting Languages
You can use other supported scripting languages in expressions, by prefixing the script quotes with the language name, for example:
metadata/createTimestamp > groovy`basic.fromNow("-P30D")`
The language name is the same as in XML filter script expressions.
Other Expression Types
If you plan to use an expression type that does not have a simplified syntax, you can use YAML expressions.
In midPoint, YAML is only available in queries. |
YAML expressions enable you to use the standard expression
element serialized in the YAML format.
This is useful when you need to define additional properties for an expression, or use other expression types that do not have a built-in syntax support.
metadata/createTimestamp > yaml``` script: language: groovy code: | now = basic.currentDateTime(); ret = basic.addDuration(now, "-P30D"); return ret ```
You have to indent the content of YAML expressions with at least one space. |