MbElementDependencyTemplateClass.CreateByElement

Syntax

CreateByElement(DictionaryKey: Integer; ElementKey: Integer);

Parameters

DictionaryKey. Key of the MDM dictionary containing the ElementKey element.

ElementKey. Key of the MDM dictionary element, on which objects depend.

Description

The CreateByElement constructor creates a new dependencies template in accordance with specified object parameters of MDM dictionary and dictionary element.

Comments

To get a dictionary key, use the IMetabaseObjectDescriptor.Key property or the IMetabase.GetObjectKeyById method.

Example

Executing the example requires that the repository contains an object with the Obj_1 identifier and an MDM dictionary with the Country identifier. Tracking of dependencies from MDM dictionary elements is enabled for an object. The dictionary is stored in the MDM repository with the RDS identifier.

Sub UserProc;
Var
    MB: IMetabase;
    Obj, Dictionary: IMetabaseObjectDescriptor;
    Elements: IRdsDictionaryElements;
    Depends: IMbElementDependencies;
    Template: IMbElementDependencyTemplate;
Begin
    MB := MetabaseClass.Active;
    Obj := MB.ItemById("Obj_1");
    Dictionary := MB.ItemByIdNamespace("Country", MB.ItemById("RDS").Key);
    Elements := (Dictionary.Open(NullAs IRdsDictionaryInstance).Elements;
    Template := New MbElementDependencyTemplateClass.CreateByElement(
        Dictionary.Key, Elements.Element(1));
    //Collection of object dependencies
    Depends := Obj.ElementDependencies;
    Depends.Add(Template);
    Mb.ElementDependenciesDatabase.Update(Depends);
End Sub UserProc;

Executing the example results in a collection of object dependencies from MDM dictionary elements. A new dependency from a specified dictionary element will be added to a list of dependencies. The list of dependencies will be saved in the repository database.

See also:

MbElementDependencyTemplateClass