Adding relations to business classes

While it's best to use existing relationships, if a business class relation isn't already defined, you can add a relation from one business classes to another. Once you have defined relations, you can add them to lists and forms. You can also use them to create user-defined fields such as Derived Fields, Conditions, and Computes.

Note: To find the existing relations in a business class, follow the steps in this task like you are going to add a one-to-one relation. The Source Value chooser in the Field Mapping will show available relations.

Be careful when you define relations (especially one-to-many relations). A poorly defined relation can cause performance issues.

If fields to relate one business class to another are not available, you can create fields first. Referencing user-defined fields of the related business class is not recommended unless the set returned from the database is small, while referencing user fields from the business class where the relation is defined is acceptable. In other words, if you need to use user-defined fields in a relation, define the relation from the same business class where you defined the new field.

  1. In the Infor Rich Client, access the Configuration Console.
  2. Select Business Classes and, if a business class configuration does not already exist for the business class you want to add the relation to, select the Create button at the top of the left pane and then select User Relation as the configuration type in the dialog box that appears. If the business class configuration already exists, expand the business class, select User Relations, and click the Create button at the top of the left pane.
  3. Select the business class for the relation, select User Relation as the configuration type, and then click OK.
  4. Define the relation.
    Relation Name

    Specify the name. It cannot begin with a lowercase letter or contain spaces. Be sure to follow your configurations naming conventions and prefix the name with a code such as ZZZ, Usr, or characters that represent your company name (for example, ACM for Acme Co).

    Relation Type

    Select One-To-One, One-To-Many, or Business Class Set.

    In most cases, you will use One-To-One or One-To-Many. A Business Class set is a short hand for defining the relation and requires an understanding of LPL source code. It will automatically map matching key field types, so it automatically fills out the Field Mapping section.

    To

    Specify the business class you want to relate to.

    Set

    Required when you select One-To-One or One-To-Many. A set is an index, a relation must be based on a set. The set defines what is available in the Field Mapping section. If you use a one-to-many relation, be sure to narrow down the set by setting upper level keys of the set.

    For a Business Class Set, it is automatically chosen and mapped.

    Valid When

    Optionally, define when the relation is valid. The possible value for this field vary by business class. You can also use the Negate check box to reverse the value.

    Delete Rule

    Define the delete rule for the relation. When you delete a record, all relations that are not Ignored (the default) are processed. If the relation is Cascades, it also deletes all of the related records for the relation. If it is Restricted, the delete will fail if any records exist for the relation.

    As Of

    Optionally, specify dates for the relation when you define a one-to-one or one-to-many relation. You can specify values here so the relation will return records as they were on the as-of-date (for past dates, using the audit log) or as they will be (for future dates, using the effective log). This has a performance impact.

    If you leave this field blank, the relation will return current data – unless an as-of-date or effective-date is applicable, then it uses that value. An as-of-date and/or effective date can be in defined in LPL. An as-of-date can also be defined via the UI, though that is not a normal case.

    In most cases, you will leave this value blank.

  5. If you are defining a one-to-one or one-to-many relation, complete the field mapping.

    The Source value is what value you want to match on for the Related field. If it’s a constant, it’s a fixed value they must enter such as "abc" for an alpha, or ‘1’ for a numeric. If it’s not a constant value, the select is available to allow them to choose fields from this business class, including related fields. For example, if you have a relation defined and one of the keys is Enterprise Group and you always want a specific Enterprise Group, you would enter a constant value.

    • In the Use for Mapping column, indicate the field(s) you want to use for the relation.

    • The Source Value is the value you want to match on for the Relation Field. If it's a constant value, you will enter a fixed value and select the Constant box in the Constant column. If it's not a constant value, you can choose fields from this business class (including related fields). The name of the source field may or may not match the name of the Related Field.

    For example, if you have a relation and one of the keys is Enterprise Group and you always want a specific Enterprise Group, enter a constant value. For any record, accessing this relation will always return the same data. The more likely scenario is that you want to map to the Enterprise Group based on the value of a field in the business class where the relation is defined. If this business class has a field called "AlternateEnterpriseGroup", you could choose that field. The relation will then be dynamic and can return different data for each record since each record may have a different value in that field.

  6. Optionally, define a condition for the relation. Type in a conditional clause or click the condition Build button to open a window where you can define the condition.

    The Field Mapping section is limited to only fields in the set. You may want to narrow down the relation results further. For example, if the related business class has EnterpriseGroup, Location, and Department but only EnterpriseGroup and Location are part of the set, and they want to return only records for a specific Department, they would need to use the Instance Selection to do this. This is not valid for a One-To-One relations since that requires filling out all keys for the set resulting in only one record (or none) based on those keys.

  7. Click the Save button at the top of the right pane.

    The new user relation is now available to be added to a list or form configuration or to be used in a user-defined field.