clear (object/collection) of (object)

The clear construct sets to null the value of an object or removes the objects of a collection.

Purpose

You use this construct in the action part of a rule to clear a collection or to remove a relationship between two objects.

Syntax

clear <object/list> of <object>

Description

The clear <object/list> keyword empties a collection or sets to null a relationship. The of <object> keyword defines the entity or event for which you want to clear the relationship or collection. For example, you can remove the car of a customer if the car no longer belongs to this customer.

You can use the clear construct on collections or on a related object. For example, you can clear the bag or bags of a customer because the customer has a relationship to a bag, and the bag is a concept that is defined independently from the customer. However, you cannot clear the age of the customer because the age is not defined as a concept in the business model. The age is a simple attribute of the customer.

Note: You cannot set or clear the ID of an entity.

Example

The following example shows that when a session is complete, the session no longer has attendees.

when a complete session event occurs
then
    set the session state of 'the session' to complete;
    clear the attendees of 'the session'; 
In the following example, when a flight is canceled, the flight no longer needs an arrival airport.
when a flight canceled event occurs
then
    clear the arrival airport of 'the flight';