MbElementDependencyTemplateClass.CreateByObject

Syntax

CreateByObject(ObjectKey: Integer);

Parameters

ObjectKey. Key of the object, for which a dependencies template is created.

Description

The CreateByObject constructor creates a new dependencies template in accordance with repository object parameters.

Comments

To get an object 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;
    DepDB: IMbElementDependenciesDatabase;
    Obj, Dictionary: IMetabaseObjectDescriptor;
    Elements: IRdsDictionaryElements;
    Depends: IMbElementDependencies;
    Template: IMbElementDependencyTemplate;
    ElemKeys: Array Of Integer;
Begin
    MB := MetabaseClass.Active;
    DepDB := MB.ElementDependenciesDatabase;
    Depends := DepDB.New_;
    Obj := MB.ItemById("Obj_1");
    //Create a template
    Template := New MbElementDependencyTemplateClass.CreateByObject(Obj.Key);
    Dictionary := MB.ItemByIdNamespace("Country", MB.ItemById("RDS").Key);
    Elements := (Dictionary.Open(NullAs IRdsDictionaryInstance).Elements;
    //Specify dictionary
    Template.DictionaryKey := Dictionary.Key;
    ElemKeys := New Integer[2];
    ElemKeys[0] := Elements.Element(1);
    ElemKeys[1] := Elements.Element(2);
    //Specify keys of elements
    Template.ElementKeys := ElemKeys;
    //Add dependencies
    Depends.Add(Template);
    Mb.ElementDependenciesDatabase.Update(Depends);
End Sub UserProc;

Executing the example results in a collection of object dependencies from MDM dictionary elements. Two dependencies from two dictionary elements will be added to a list of dependencies. The list of dependencies will be saved in the repository database.

See also:

MbElementDependencyTemplateClass