Check access to a custom operation

Syntax

$object.canExecute($operation)

canExecute($object, $operation)

Description

Checks whether the currently logged-in user is allowed to perform a custom business operation on the given object and returns a boolean.

The operation is referenced by its command group id (e.g. "Approve"). This is the generic check behind custom operations that go beyond read/write/delete. The function never fails (except when the named operation does not exist) and never filters.

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.

Parameters

Name Type Type Description Mandatory Default
object Business object The object on which the operation would be performed. yes
operation String The id of the command group (operation) to check, e.g. a built-in group like "Delete" or a custom one like "Approve". yes

Return value

Type: Boolean

true if the current user may perform the operation on the object, false otherwise. Fails if no command group with the given id exists.

Examples

Example 1

$order.canExecute("Approve")

Output: Whether the logged-in user may approve the order.