Syntax

$parent.canCreate($reference)

canCreate($parent, $reference)

canCreate($parent, $reference, $type)

Description

Checks whether the currently logged-in user is allowed to create a new element in the given composition reference of the given parent object and returns a boolean.

The user needs the create right on the type of the new element in the context of the parent object and the write access to the composition reference (the same check that gates adding an element to the reference). By default, the type of the new element is the target type of the reference. If an element of a specialization is to be created, its type is given as third argument; then the create right on this specialization is checked. The function never filters and fails only if the given type is not compatible with the target type of the reference.

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
parentBusiness objectThe container object that will hold the new element.yes
referenceAttributeThe composition reference (TLStructuredTypePart) into which the element is created.yes
typeTypeThe type of the element to create. Must be the target type of the reference or a specialization of it.noThe target type of the reference.

Return value

Type: Boolean

true if the current user may create an element in the given reference of the parent, false otherwise.

Examples

Example 1

$project.canCreate(`my.module:Project#milestones`)

Output: Whether the logged-in user may add a milestone to the project.

Example 2

$project.canCreate(`my.module:Project#milestones`, `my.module:FinalMilestone`)

Output: Whether the logged-in user may add a final milestone (a specialization of the milestone type) to the project.