from (object)

This construct accesses data from objects that are related to known objects.

Purpose

You use this construct to expand the set of data that can be used by a rule.

Syntax

from <object>

Description

By default, rules are used to process a set of data established by the developer of an application. If you need to access data that is not in this set, but related to a data object in this set, you can use the from construct to define a variable that pulls a data object in from a related object.

The from construct is used to retrieve one distinct object from another one. You cannot use it to retrieve a collection of objects. To access a collection of objects, use the in (list) construct.

Example

The following rule declares a variable based on the relationship between a customer and the customer’s preferred item.

definitions
    set 'preferred CD' to a CD
        from the preferred item of 'the customer';
if
     the price of 'preferred CD' is more than 25
then...

By default, the rule engine does not know what a "CD" object is. To write a rule that uses a CD object, you must first declare a variable of type CD that pulls in data from the preferred item object of the customer. This is possible because the customer object (and therefore the customer’s preferred item) is already known to the rule engine.