$object.canRead()
canRead($object)
Checks whether the currently logged-in user is allowed to read the given object and returns a boolean.
In contrast to the implicit security enforcement when accessing attributes (which returns the empty value for a non-readable object), this function never fails and never filters. It lets a script branch explicitly on missing rights – for example to implement an alternative control flow for objects that must not be shown.
The check is evaluated for the currently logged-in user and follows the same rules as the implicit permission enforcement: deny-by-default, role inheritance along the security hierarchy, and full access for administrators or executions in a system context.
| Name | Type | Type Description | Mandatory | Default |
|---|---|---|---|---|
| object | Business object | The object whose read access is checked. | yes |
Type: Boolean
true if the current user may read the object, false otherwise (in particular for null).
all(`my.module:Contract`).filter(c -> $c.canRead())
Output: All contracts that the logged-in user is allowed to read.
if($contract.canRead(), $contract.get(`my.module:Contract#name`), "(not visible)")
Output: The contract name if it is readable, otherwise a placeholder – without provoking a permission error.