Relationship Direction

Relationship direction can be a confusing concept when used in select expressions. The confusion arises because relationships are also objects, and, during a select navigation, they are treated just like business objects.

The direction terms (to and from) yield different results depending on the point-of-view of their use. If used from a business object, they mean "navigate to the relationships whose from/to end is connected to this business object."

The following expression means go to the RELNAME relationship whose from end is connected to the object:

from.relationship[RELNAME]

Having reached the relationship, it is possible to get information, such as an attribute value.

Suppose the Assembly is connected with the relationship, As Designed, to another object (Component) and that you want to use the Effectivity attribute in the relationship.

Example 1:

The table below shows how this information is obtained with the MQL print command and also how it could be used in finds, tables, and so on.

MQL print Command Find or Visuals where clause Table, Report, Form Field

Select

Expression

print bus Assembly 9000 A select from [As Designed]. attribute [effectivity];

Type == Assembly && from[As Designed]. attribute [effectivity] >12-31-99

from[As Designed]. attribute [effectivity]

Result

MQL returns:

attribute [effectivity] = 1-1-99

Assembly 90000 A is found, and if in a cue, the visuals are applied.

If Assembly 90000 A is in the table/report/form, 1-1-99 is output in that column/field.

Example 2:

Suppose there are, in fact, many objects connected to the Assembly and you want only Component 34562 B. In this case, you need to also specify the Component. In this example (from the relationship viewpoint), from and to refer to the business objects at the ends of the relationship. So, in the following expression, from refers to a relationship and to refers to a business object:

from.relationship[As Designed].to

For example:

MQL print Command Find or Visuals where clause Table, Report, Form Field

Select

Expression

print bus Assembly 9000 A select from [As Designed].to;

from[As Designed]. to.type == Component && from [As Designed]. to.name == 34562 && from[As Designed]. to.rev == B

from [As Designed].to

Result

MQL returns all objects (including Component 34562 B) that are connected to Assembly 90000 A with the relationship As Designed at the to end.

Assembly 90000 is found and, if in a cue, the visuals are applied.

If Assembly 90000 A is in the table/report/form, Component 34562 B is output in that column/field.

Example 3:

Another example finds an attribute value in the business object on the to end:

MQL print Command Find or Visuals where clause Table, Report, Form Field

Select

Expression

print bus Assembly 90000 A select from [As Designed] .to.attribute[cost].

from[As Designed].to .attribute[cost] < 100

(or >= 40, etc.)

from [As Designed].to.attribute[cost]

Result

MQL returns:

43

Assembly 90000 A is found, and if in a cue, the visuals are applied.

If Assembly 90000 A is in the table/report/form, 43, is output in that column/field.