Syntax

$object.canDelete()

canDelete($object)

Description

Checks whether the currently logged-in user is allowed to delete the given object and returns a boolean.

The function never fails and never filters; it lets a script check delete access up front instead of running into the permission error that delete would raise for a non-deletable object.

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

NameTypeType DescriptionMandatoryDefault
objectBusiness objectThe object whose delete access is checked.yes

Return value

Type: Boolean

true if the current user may delete the object, false otherwise (in particular for null).

Examples

Example 1

if($obsolete.canDelete(), $obsolete.delete(), null)

Output: Deletes the object only if the logged-in user is allowed to – otherwise nothing happens, without a permission error.